Jump to content

why date wont edit


Ameslee

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>
Link to comment
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.