I have 2 forms, on 2 different pages. I have to use a select list from the previous page to make the user select the State they live in. According to that state, i will go in my database and display all the CLUBS in their State at the TOP of the list and the rest below them in the same list. The problem or query i have is, i know how to display all clubs that from their state, but i have no idea how to display them at the top of the list while showing all other clubs. Can anyone help?
<?php
session_start();
$states = $_SESSION["stateslected"];
$conn = mysql_connect("localhost", "xxxx", "xxxx");
mysql_select_db("xxxx", $conn)
or die ('Database not found ' . mysql_error() );
$sql = mysql_query("SELECT clubName FROM teams WHERE homeState = '$states' ");
echo "<select name = 'clubs'>\n";
while ($data = mysql_fetch_array($sql, MYSQL_ASSOC))
{
echo "<option value='{$data['clubName']}'>{$data['clubName']}</option>\n";
}
echo "</select>\n";
mysql_close($conn);
?>
So with that, if the user selects OK on previous page, it should display
- OKC Thunder (Oklahoma Team)
- LA Lakers (Random Team)
- NY Knicks (Random Team)
- etc.. (Random Team)
instead of just
- OKC Thunder (Oklahoma Team)
OR
If a user selects CAL (California), it should display
- LA Lakers (California Team)
- LA Clippers (California Team)
- MI Heat (Random Team)
- BK Nets (Random Team)
- etc..
instead of just
- LA Lakers (California Team)
- LA Clippers (California Team)