engelsol Posted July 13, 2007 Share Posted July 13, 2007 I am trying to update all record with a new date format. But it just take the last record date in the query and fill everything with that same date....please help $q = "SELECT * FROM table_stories"; $result = mysql_query($q); while ($row = mysql_fetch_array($result)) { $storyid = $row["story_id"]; $edition_date = $row["edition_id"]; $edition_year = substr($edition_date,-4); $edition_month = substr($edition_date,0, 2); $edition_day = substr($edition_date,-6, 2); $new_edition_fotmat = "$edition_year$edition_month$edition_day"; $q = "UPDATE table_stories SET edition_id = '$new_edition_fotmat , created_stamp = '$edition_year-$edition_month-$edition_day' , modified_stamp = '$edition_year-$edition_month-$edition_day' , published_stamp = '$edition_year-$edition_month-$edition_day' "; mysql_query($q); } Thanks in advance Engel Link to comment https://forums.phpfreaks.com/topic/59803-solved-what-is-wrong-with-this-simple-code/ Share on other sites More sharing options...
GingerRobot Posted July 13, 2007 Share Posted July 13, 2007 You're missing a where clause from your UPDATE query. Im guessing it was supposed to be: <?php $q = "UPDATE table_stories SET edition_id = '$new_edition_fotmat , created_stamp = '$edition_year-$edition_month-$edition_day' , modified_stamp = '$edition_year-$edition_month-$edition_day' , published_stamp = '$edition_year-$edition_month-$edition_day' WHERE story_id = '$storyid' "; mysql_query($q); ?> Link to comment https://forums.phpfreaks.com/topic/59803-solved-what-is-wrong-with-this-simple-code/#findComment-297358 Share on other sites More sharing options...
engelsol Posted July 13, 2007 Author Share Posted July 13, 2007 thanks a lot. It works!! Link to comment https://forums.phpfreaks.com/topic/59803-solved-what-is-wrong-with-this-simple-code/#findComment-297365 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.