Jump to content

Archived

This topic is now archived and is closed to further replies.

Ameslee

why date wont edit

Recommended Posts

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 include

include("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 format
switch(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>

Share this post


Link to post
Share on other sites
Greetings Ames

I'm a noob too, so I'm not 100% sure about everything you need to do to get this working right...BUT

If 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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.