my database named "dates" , table is "apps" columns are "app" wich stored appointments there and another column named "available" which cointain status of the appointment [yes/no] and need to be updated after user submit a specific "app" from the drop downlist.
Code: Select all
<?php
$con = mysql_connect("localhost","root","root");
$result=@mysql_query("select app from dates.apps where available='yes'");
echo"<form action='db_update.php' method='post'>";
print "<p>select an appointment:\n";
print "<select name=appointment>\n";
while($row=mysql_fetch_assoc($result))
{
$appointment=$row['app'];
print"<option value=$appointment/>$appointment\n";
}
print"</select>\n";
echo'<input type="submit"/>';
mysql_close($con);
?>
Code: Select all
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dates", $con);
mysql_query("update apps set available='no' where app='$_post[appointment]'");
mysql_close($con);
?>