Hi guys,
Iam working on this project for some time now and i really need the help of an expert.
The goal is to get the info of the selected team from the db table "teams".
As you can see,there is a dropdown box (named "cat") which displays the teams (non dynamic display though) and passes the selected option through the $_REQUEST['subcat'] to index8.php.
The next step is to search in the DB for the team that has the same ID as the $_REQUEST['subcat'] and return the relevant info.
The problem is that the 2nd dropdown wont populate... ANY HELP?!?!?!?
The javascript
<script>
function reload(form1){
var subcat= form1.cat.options[form1.cat.options.selectedIndex].value;
self.location = 'index8.php?subcat='+subcat;
}
</script>
Main piece of code
:xbones:I've omitted the connection details so nevermind that:xbones:
<body>
<form name="form1">
<select name="cat" onchange="reload(this.form);">
<option value="0">- All Teams -</option>
<option value="1">Liverpool FC</option>
<option value="2">Manchester Fc</option>
<option value="3">Arsenal FC</option>
</select>
</form>
<?php
if(isset($_REQUEST['subcat'])){
$pop=$_REQUEST['subcat'];
//echo "request value= ".$_REQUEST['subcat']. "\n";
//display your sub category select form here
$query = mysql_query ("SELECT * FROM teams WHERE id='$pop'");
if (!$query) {
echo 'Could not run query: ' . mysql_error();
exit;
}
else{
//echo "elseif state= ".$pop. "\n";
//dont forget to filter out bad strings!
//$res=mysql_fetch_row($query);
while($res=mysql_fetch_array($query));
$rows = mysql_num_rows($query);
if($rows > 0)
{
echo "hello";
echo "inside while loop= $pop". "\n";
echo $res[id];
echo "<option value='$res[id]'>$res[name]</option>";
echo "</select>";
}
else echo 'Could not fill 2nd dropdown!!!';
}
}
else echo 'Subcat is empty!!!';
//echo mysql_result($res, 2). "\n";
//mysql_close($link);
?>
</body>
Thanks for taking the time to look at my post.
Good day to all!