这是代码:
<select name="op1" id="op1" class="op1">
<option value=""> -- please choose -- </option>
<?php
while($row = mysql_fetch_array($query)){
$id = $row['id'];
$name = $row['name'];
echo '<option value="'.$id.'">'.$name.'</option>';
}
?>
</select>
<br />
<select name="op2" id="op2" style="margin-top:20px" class="op2">
<option value=""> -- please choose -- </option>
<?php
$query2 = mysql_query("SELECT * FROM cat2 WHERE cor = '$id' ORDER BY id ASC");
while($row2 = mysql_fetch_array($query2)){
$id2 = $row2['id'];
$name2 = $row2['name'];
echo '<option value="'.$id2.'">'.$name2.'</option>';
}
?>
</select>
我想要做的是从第一个循环中选择 $id 并在第二个循环查询中使用它,但由于管道可变,似乎无法让它工作,有人知道解决这个问题吗?