0

I'm hoping for a simple solution to my ever annoying problem. I have looked online and in books. I need to display results from my drop down menu. It is currently connected to the database/table and displaying the l_state as needed. All I need now is, when the state is selected, I hit submit and the information in the table is displayed below the drop down/submit button. Here is my code so far.

//db_connect included at top

$sql="SELECT * FROM licensing ORDER BY l_state DESC"; 
$result=mysql_query($sql); 

$options=""; 

while ($row=mysql_fetch_array($result)) { 

  $id=$row["id"]; 
  $url=$row["l_url"]; 
  $phone=$row["l_phone"]; 
  $state=$row["l_state"];
  $sullstate=$row["l_statefull"];  
  $options.="<option value=\"$id\">".$state; 
} 


<select name="listing">

<select name="listing"><option value=0>Choose<?=$options?></option></select>
<input type="submit" value="Search"/>

So if there is anyone out there that can help me with an answer?

4

2 回答 2

0

更改此行

$options .="<option value=\"$id\">".$state ."</option>"; 

和这样的HTML部分

<select name="listing">
  <option value=0>Choose</option>
  <?php echo $options ;?>
</select>
于 2012-12-19T06:47:31.290 回答
0

您需要检查当前页面是否已提交(或提交到其他页面)。

这可以使用 if(isset($_POST)) 或 if($_REQUEST['POST']),然后您需要构建查询并将发布的数据包含在查询中(确保为此使用转义)。

于 2012-12-19T06:49:07.863 回答