Forum Moderators: coopster
Timeid-----day---------time
--1-------Monday--------5 - 7pm
--2-------Tuesday-------5 - 7pm
--3-------Wednesday-----5 - 7pm
--4-------Thursday------5 - 7pm
--5-------Friday--------4.30pm - 6.30pm
--6-------Saturday------5 - 6pm
--7-------Sunday--------5 - 6pm
I wish to have the time for each day displayed in a text field so i use the following...
$query = "SELECT * FROM coursetimes";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$day=$row['day'];
$daytime=$row['time'];
$timeid=$row['timeid'];
$data_cells .=<<<HTML
<tr>
<td><p>$day:</p></td>
<td><input type = "text" size="15" name = "$day" value = "$daytime" maxlength="10"></td>
</tr>
HTML;
} this works fine but on the form if the user edits the times in the text field and clicks update i wish the database times to be updated, how can i do this?! im using...
if (isset($_GET['update']))
{
$query="UPDATE coursetimes SET time = '$daytime' WHERE timeid = '$timeid'";
mysql_query($query) or die(mysql_error());
$complete = "updated";
}
but this is not working :( can anybody help?
thanks
$query = "SELECT * FROM coursetimes";
$result = mysql_query($query);while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$day=$row['day'];
$daytime=$row['time'];
$timeid=$row['timeid'];
$data_cells .=<<<HTML
<tr>
<td><p>$day:</p></td>
<td><input type = "text" size="15" name = "$timeid" value = "$daytime" maxlength="10"></td>
</tr>
HTML;
}
which is working, and the update which is not working is...
if (isset($_GET['update']))
{
$query="UPDATE coursetimes SET time = '$daytime' WHERE timeid = '$timeid'";
mysql_query($query) or die(mysql_error());
$complete = "updated";
} can anybody help me with the update please?!
thanks
==in update==
//query to table
while .....
{
// make new var (day_Monday, day_Friday, etc)
$my_id = "day_".$row['Timeid'];
$my_val = $$my_id;
if ($my_val!="")
{
$query="UPDATE coursetimes SET time = '$my_val' WHERE timeid = '".$row['Timeid']."'";
{
}