Hello ppl,
I have in my site a news sistem, I made it myself, and I have a problem when I made an
update of the news (when I insert news).
The db has a field named actual if this field is 1 then the news will be shown on the site,
and if the value of actual is 0 the news will be shown only in archive.
The sistem works like this:
When I insert new news I have two radio buttons one amed actual, one has the value 0 and one 1,
at the first news I write the button will be set to 0, so you can see in the script, that the
news where was actual = 1 will be set to 0 and after that the news I posted will be inserted
with actual = 1. The next news I write wil have the actual button set to 1 and will be only
inserted in the db.
The problem is with the column named timestamp. When I set the actual = 0, at the first news
I write, the timestamp of the old news with the actual = 1 will be $current_date, why this is
happening, 'cause the update query is just :
mysql_query("UPDATE stiri set actual='0' WHERE actual='1'");
Here is all the code:
<?
require("db.inc.php"); //connect to the database
if($action=="submit")
{
//here I insert the news, no update to other news
if($actual == '1'){
$current_date=date("Ymd");
mysql_query("INSERT INTO stiri (subject,content,timestamp,small,actual) VALUES
('$news_subject','$news_content','$current_date', '$small', '$actual')");
echo "Stirea a fost inregistrata!<br>\n";
}
else{
echo "Toate stirile de pana acum vor fi setate cu <b>actual = 0</b><br>\n";
//here i set the old news to `actual` = 0 and after I insert news
mysql_query("UPDATE stiri set actual='0' WHERE actual='1'");
$current_date=date("Ymd");
mysql_query("INSERT INTO stiri (subject,content,timestamp,small,actual) VALUES
('$news_subject','$news_content','$current_date', '$small', '1')");
echo "Stirea a fost inregistrata!";
}
}
?>
If you know what's wrong to the that query pls post me an reply.
10x and see ya all.