Hey guys I am having some issues... I am new to coding so most of the stuff I have is from other forums and friends helping me out but I am stuck.
I have a table pulling from a mySQL database database name is
daobrien21 the tables name is
Test below is the code for the data base and table and drop down
Code:
<?php
$connect = mysql_connect("hosted.domain.com", "username", "password") or
die ("Hey loser, check your server connection.");
mysql_select_db("daobrien21");
?>
<?php
// Write out our query to get the list of bar names from our DB.
$query = "SELECT Bar FROM Test";
// Execute it, or return the error message if there's a problem.
$result = mysql_query($query) or die(mysql_error());
$dropdown = "<select name='Bar'>";
//fetch_assoc will get the rows from the $result and put them into an array
// the while loop then loops through the array wrapping the html code around the results
// thus generating the dropdown with a list of your bar names
while($row = mysql_fetch_assoc($result)) {
$dropdown .= "\r\n<option value='{$row['Bar']}'>{$row['Bar']}</option>";
}
$dropdown .= "\r\n</select>";
echo $dropdown;
?>
<?php
$query="select * from Test";
$result = mysql_query("SELECT * FROM Test where City='Murfreesboro'");
?>
<table border=1 style="background-color:#F0F8FF;" >
<caption><EM>Murfreesboro Bars</EM></caption>
<tr>
<th>Bar Name</th>
<th>City</th>
<th>Address</th>
<th>Phone</th>
</tr>
<?php
while($row=mysql_fetch_array($result)){
echo "</td><td>";
echo $row['Bar'];
echo "</td><td>";
echo $row['City'];
echo "</td><td>";
echo $row['Address'];
echo "</td><td>";
echo $row['Phone'];
echo "</td></tr>";
}
echo "</table>";
?>
What I am looking for is when I select a bar name in the drop down it filters the table to only display that bar in it. Can you guys help me out please.