influence01 Posted November 28, 2007 Share Posted November 28, 2007 have a list of webcasts that are loaded into MySQL DB. There are times when I need to change a field, such as, the date, time or others on the record. All the other fields accept the update and display correctly in the list, except the t_Time. For some reason, the time remains at 6:00 PM and displays 12:00 AM in the options. Of which, neither are valid selections. This is the code I have to display the results in a list. The time never changes to display the one selected. // Perform database query $result = mysql_query("SELECT *, date_format(d_Date, '%a. %b %d, %Y') AS date, date_format(d_Date, '%a. ') AS day, date_format(t_Time, '%h:%i') AS time FROM tblWebcasts ORDER BY d_Date DESC", $connection); if(!$result) { die("Database query failed. Please report this error to web site administrator"); } $count = 0; while ($line = mysql_fetch_array($result)) { echo (" <!-- Begin Record -->"); echo (" <tr>"); echo (" <td><div align=right>" . $line['date'] . "</div></td>"); echo (" <td><div align=center>" . date("h:i A", strtotime($line['time'])) . "</div></td>"); This is the code I have to recieve the user selections and update the DB. The time is echo correctly, but when I return to the list, it has not changed. $myDate = $_POST['d_Date'] ; $myTime = $_POST['t_Time'] ; if (!$_POST['c_Title2'] == "") { $myTitle = addslashes($_POST['c_Title2']); } else { $myTitle = addslashes($_POST['c_Title']); } if (!$_POST['c_Speaker2'] == "") { $mySpeaker = addslashes($_POST['c_Speaker2']); } else { $mySpeaker = addslashes($_POST['c_Speaker']); } $myFilename = $_POST['c_Filename'] ; $myId = $_POST['i_Id'] ; echo ($myDate . "<br>"); echo ($myTime . "<br>"); echo ($myTitle . "<br>"); echo ($mySpeaker . "<br>"); echo ($myFilename . "<br>"); echo ($myId . "<br>"); //Perform database query $query="UPDATE tblWebcasts SET d_Date = '$myDate', t_Time = '$myTime', c_Title = '$myTitle', c_Speaker = '$mySpeaker', c_Filename = '$myFilename' WHERE i_Id = '$myId'"; mysql_query($query); echo("The webcast has been updated successfully!"); mysql_close(); ?> This is the code that provides fields to be modified. The first option is suppose to display the code in the DB. It doesn't. <?php> $i_Id=$_GET['i_Id']; // Perform database query $result = mysql_query("SELECT * FROM tblWebcasts WHERE i_Id='$i_Id'"); if(!$result) { die("Database query failed. Please report this error to web site administrator"); } $row = mysql_fetch_assoc($result); $myTime = date("g:i A", strtotime($row['t_Time'])); ?> <tr bgcolor="#3D3D3D"> <td colspan="2" bgcolor="#3D3D3D" class="reverse"><div align="right">Time of Day: </div></td> <td colspan="2"><div align="left"> <select name="t_Time" size="1" id="t_Time"> <option value="<?php echo $row['t_Time'] ?>" selected><?php echo $myTime; ?></option> <option value="09:30:00">9:30 AM</option> <option value="10:30:00">10:30 AM</option> <option value="18:30:00">6:30 PM</option> <option value="19:00:00">7:00 PM</option> </select> </div></td> </tr> 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.