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 Quote Link to comment 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); ?> Quote Link to comment Share on other sites More sharing options...
engelsol Posted July 13, 2007 Author Share Posted July 13, 2007 thanks a lot. It works!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.