Forums

PHP

This topic is locked

making list based on dropdown input

Posted 20 Apr 2006 23:25:17
1
has voted
20 Apr 2006 23:25:17 Louis Hebben posted:
I want to have my page make a list of hylerlinks based on the input from a dropdown list. I have figured out how to dynamically populate the list. The page should then use the input as a header and make the list below the header. I can get the header to display correctly but the list dosn't work. The SQL line I am using works when the "category" is hard coded, but not from the dropdown. Also, is there a way to make the list show the selected category instead of always the first item? www.camoracer.com/othersites.php

<form method="post" action="<?php echo $PHP_SELF;?>">
<select name="Sites">
<?php
$query = "SELECT `category` FROM `categories` order by category asc";
$result = mysql_query($query);
while(list($category)=mysql_fetch_row($result))
{
echo "<option value=".$category.">".$category."</option>";
}
echo "</select>";
echo "<input type=\"submit\" value=\"submit\" name=\"choice\">";
echo "</FORM>";
$choice=$_POST["Sites"];
//if (!isset($_POST['submit']));
echo "<br>";
//Start of site listing
echo "<hr width=\"50%\" align=\"left\">";
echo "<h1>".$choice."</h1>";
$query = "SELECT name, site FROM websites WHERE category= " .$choice. "";
$result = mysql_query($query);
while(list($name,$site)=mysql_fetch_row($result))
{
echo "<a href=".$site.">".$name." </a>";
echo "<br>";
}
echo "<hr width=\"50%\" align=\"left\">";
//****************************************************************
?>

Edited by - camoracer on 20 Apr 2006 23:27:17

Reply to this topic