Being a n00b to php I really could use a little help.
I have a drop down list populated by information in a database:
<?php
include_once('../other/functions.php');
$con = mysql_connect($hostname, $username, $password)
OR DIE ('Unable to connect to database! Please try again later.');
$db = mysql_select_db($dbname, $con);
$sql="SELECT owner_id, teamname FROM owners WHERE active = 1 ORDER BY division, teamname";
$result=mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result)) {
$id=$row["owner_id"];
$thing=$row["teamname"];
$options.="<OPTION VALUE=\"$id\">".$thing.'</option>';
}
mysql_close($con);
?>
<SELECT NAME=thing>
<OPTION VALUE=0>Choose One
<?=$options?>
</OPTION>
</SELECT>
I understand that I have to get the WHERE clause to mimic the drop down list selection instead of setting it to standings.owner_id=1. Other then that I have the query that will get the information I want into a table:
<?php
$con = mysql_connect($hostname, $username, $password)
OR DIE ('Unable to connect to database! Please try again later.');
$db = mysql_select_db($dbname, $con);
$query = "SELECT * FROM standings, owners, divisions WHERE owners.owner_id = standings.owner_id AND owners.division = divisions.division AND standings.owner_id = 1 ORDER BY year";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
mysql_data_seek($result, 0);
echo "<table CELLPADDING=5 border =1>";
echo "<tr>";
echo "<th align=center colspan = 2> Team Name </th>";
echo "<th align=center> Team Owner </th>";
echo "<th align=center> Conference </th>";
echo "<th align=center> Division </th>";
echo "</tr>";
echo "<tr>";
echo "<td align=center colspan = 2>".$row['teamname']."</td>";
echo "<td align=center>".$row['firstname']."</td>";
echo "<td align=center>".$row['conference']."</td>";
echo "<td align=center>".$row['division']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th align=center> Year </th>";
echo "<th align=center> Wins </th>";
echo "<th align=center> Losses </th>";
echo "<th align=center> Points For </th>";
echo "<th align=center> Points Against </th>";
echo "</tr>";
$row = mysql_fetch_array($result);
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td align=center>".$row['year']."</td>";
echo "<td align=center>".$row['win']."</td>";
echo "<td align=center>".$row['loss']."</td>";
echo "<td align=center>".$row['points_for']."</td>";
echo "<td align=center>".$row['points_against']."</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
How do I make it so a user can use the drop down list, select a team name, and the query will then display the info?? And since I am really really really new to this please be specific and show examples or lord knows I will be asking how to fix what I just broke LOL.
Thank you very much