How do I control select box 2's output based on what is selected in select box 1?
If I select Record 1 from Select Box 1, it outputs the Record 1 ID in header. I want to output all Records in Select Box 2 with Record 1 ID.
How do I implement this, is my SQL select statement incorrect? Do I need to say something like:
Edit Please delete.
$quer=mysql_query("SELECT DISTINCT projectName, projectID
FROM projects
WHERE clientID=$cat
ORDER BY projectName");
Above works.
else {
$quer=mysql_query("SELECT DISTINCT projectName, projectID
FROM projects
WHERE projectID = $cat
ORDER BY projectName"); }
Above doesn't work but I feel I'm close but no cigar?
<?php
@$cat=$_GET['cat'];
if(strlen($cat) > 0 and !is_numeric($cat)) {
echo "Data Error";
exit;
}
$quer2 = mysql_query("SELECT DISTINCT clientName,clientID
FROM clients
ORDER BY clientName");
if(isset($cat) and strlen($cat) > 0) {
$quer = mysql_query("SELECT DISTINCT projectName
FROM projects
WHERE projectID = $cat
ORDER BY projectName");
} else {
$quer = mysql_query("SELECT DISTINCT projectName
FROM projects
ORDER BY projectName");
}
echo "<form method=post name=f1 action='dd-check.php'>";
echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>";
while ($noticia2 = mysql_fetch_array($quer2)) {
if ($noticia2['clientID'] == @$cat) {
echo "<option selected val开发者_如何学Cue='$noticia2[clientID]'>$noticia2[clientName]</option>"."<BR>";
} else {
echo "<option value='$noticia2[clientID]'>$noticia2[clientName]</option>";
}
}
echo "</select>";
echo "<select name='subcat'><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($quer)) {
echo "<option value='$noticia[projectName]'>$noticia[projectName]</option>";
}
echo "</select>";
echo "<input type=submit value=Submit>";
echo "</form>";
?>
精彩评论