Ameslee Posted April 19, 2006 Share Posted April 19, 2006 Can anyone tell me why, when i go to edit and put a date in, and then go back and display the record it hasnt edited. The code is below, let me know if u need any other pages.... Thanks<html><head><title>Edit Event Details</title></head><body><form method=POST action="adv_edit_record3.php"><h3>Edit Event Details</h3><?php//databse includeinclude("database.inc");$query = "select * from `events` where eventid=$id";$mysql_result=mysql_query($query,$conn);$row=mysql_fetch_row($mysql_result);//work on the date so it can be displayed in the select$date=$row[11]; //The date is the element in index 11 of the row array$day=substr($date,8,2); //extract the day from the date$month=substr($date,5,2); //extract the month from the date$year=substr($date,0,4); //extract the year from the date//use switch to set the long month formatswitch(TRUE){case ($month==1): $newmonth="January"; break;case ($month==2): $newmonth="February"; break;case ($month==3): $newmonth="March"; break;case ($month==4): $newmonth="April"; break;case ($month==5): $newmonth="May"; break;case ($month==6): $newmonth="June"; break;case ($month==7): $newmonth="July"; break;case ($month==8): $newmonth="August"; break;case ($month==9): $newmonth="September"; break;case ($month==10): $newmonth="October"; break;case ($month==11): $newmonth="November"; break;case ($month==12): $newmonth="December"; break;}echo <<<events<table><tr><td><input type="hidden" name="eventid" value="$row[0]">Event<td><input type="text" name="event" value="$row[1]"><tr><td>Date<td><select name="month"><option value="$month">$newmonth</option><option value="01">January</option><option value="02">February</option><option value="03">March</option><option value="04">April</option><option value="05">May</option><option value="06">June</option><option value="07">July</option><option value="08">August</option><option value="09">September</option><option value="10">October</option><option value="11">November</option><option value="12">December</option></select><select name="day"><option value="$day">$day</option>events;$x=1;while($x<=31){ echo "<option value=$x>$x</option>"; $x++;}echo "</select>";echo "<select name='year'>";echo "<option value=$year>$year</option>";$y=2006;while($y<=2020){ echo "<option value=$y>$y</option>";$y++;}echo <<<display</select><tr><td>Cost<td><input type="text" name="cost" value="$row[3]"><tr><td>Other Info<td><textarea name="otherinfo" row="5" cols="30">$row[4]</textarea><tr><td>Contact Person<td><input type="text" name="contactperson" value="$row[5]"><tr><td>Contact No<td><input type="text" name="contactno" value="$row[6]"> <tr><td>Mobile<td><input type="text" name="mobile" value="$row[7]"> </table><p><input type="submit" value="Edit Details">display;?></form></body></html> Quote Link to comment https://forums.phpfreaks.com/topic/7821-why-date-wont-edit/ Share on other sites More sharing options...
freshrod Posted April 19, 2006 Share Posted April 19, 2006 Greetings AmesI'm a noob too, so I'm not 100% sure about everything you need to do to get this working right...BUTIf you want to edit data in the DB you need to use an UPDATE command. I think after you have retrieved the data, displayed it in a form, edited the data, then you need to add another query that updates the data to the DB.Example: $query = "UPDATE * FROM `events`WHERE eventid=$id";I hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/7821-why-date-wont-edit/#findComment-28585 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.