There are two things that I would like to have happen, but don't know how to do.
1) Set the dropdown lists so that they don't repeat same information... like days of the week for instance.
2) Have the ability to select information from the drop down lists to narrow down the information displayed in the main table.
Can anyone help me out with this? Thank you for any help in advance.
Code: Select all
<form action="">
Where would you like to take the class?<br>
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("username_redcross", $con);
$query="SELECT location FROM take_a_class";
$result = mysql_query($query);
echo "<select name=location value=''>Select Location</option>";
while($nt=mysql_fetch_array($result)){
echo "<option value=$nt[location]>$nt[location]</option>";
}
echo "</select>";
?>
<br><br>
On which date would you like to take the class?<br>
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("username_redcross", $con);
$query="SELECT date FROM take_a_class";
$result = mysql_query($query);
echo "<select name=date value=''>Select Date</option>";
while($nt=mysql_fetch_array($result)){
echo "<option value=$nt[date]>$nt[date]</option>";
}
echo "</select>";
?>
<br><br>
Which day of the week is best for you?<br>
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("username_redcross", $con);
$query="SELECT day FROM take_a_class";
$result = mysql_query($query);
echo "<select name=day value=''>Select Day</option>";
while($nt=mysql_fetch_array($result)){
echo "<option value=$nt[day]>$nt[day]</option>";
}
echo "</select>";
?>
</select>
<br><br>
Which time of day is best for you?<br>
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("username_redcross", $con);
$query="SELECT time FROM take_a_class";
$result = mysql_query($query);
echo "<select name=time value=''>Select Time</option>";
while($nt=mysql_fetch_array($result)){
echo "<option value=$nt[time]>$nt[time]</option>";
}
echo "</select>";
?>
<br><br>
</form>
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("username_redcross", $con);
$result = mysql_query("SELECT * FROM take_a_class");
echo "<table border='1'>
<tr>
<th>Class Type</th>
<th>Location</th>
<th>Date</th>
<th>Day</th>
<th>Time</th>
<th>Phone</th>
</tr>";while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['class_type'] . "</td>";
echo "<td>" . $row['location'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['day'] . "</td>";
echo "<td>" . $row['time'] . "</td>";
echo "<td>" . $row['phone'] . "</td>";
echo "</tr>";
}
echo "</table>";mysql_close($con);
?>