2015-11-05 54 views
1

我有下拉编辑表单。 所有ISBN记录都列在下拉列表中。用户将选择他想要更新的ISBN。现在如何获得该用户选择哪个ISBN记录? 我的下拉菜单的逻辑如下:如何获取在其他页面上选择的值?

function update() 
{ 
$select_query="Select ISBN from book"; 
$select_query_run = mysql_query($select_query); 
echo"<form method='post' action='update.php'><center>Select ISBN you want to Update: "; 
echo "<select name='isbn' id='isbn'>"; 
while ($select_query_array=mysql_fetch_array($select_query_run)) 
{ 
    echo "<option value='' >".htmlspecialchars($select_query_array["ISBN"])." </option>"; 
} 
echo "</select>"; 
echo '<br><br><br><input type="submit" value="Update"></center></form>'; 
} After selecting ISBN the user will be navigated to update php page whoch is as follow: 

<?php 
$isbn=$_POST['isbn']; 
echo "ISBN Selected: ".$isbn; 
?> 

更新页面的输出: ISBN选择:

回答

0

为此,您应该试试这个:

echo "<option value='' >".htmlspecialchars($select_query_array["ISBN"])." </option>"; 

取而代之的是:

echo "<option value='".htmlspecialchars($select_query_array['ISBN'])."' >".htmlspecialchars($select_query_array["ISBN"])." </option>"; 
1

因为你的价值是在选择框中

echo "<option value='' >".htmlspecialchars($select_query_array["ISBN"])." </option>"; 
        ^^ 

空则需要在增加价值您的选择框

echo "<option value='".htmlspecialchars($select_query_array['ISBN'])."' >".htmlspecialchars($select_query_array["ISBN"])." </option>"; 
+0

并设置属性'selected'到''

+1

将由用户选择不是他 – achecopar

+0

是的,它会根据用户选择 – Saty

相关问题