Php drop down menu
i am using following code to insert data into mysql database
<?php
$refselect = $_POST['refselect'];
$refname = $_POST['refname'];
$refemail = $_POST开发者_开发问答['refemail'];
$refcnt = $_POST['refcnt'];
$refdes = $_POST['refdes'];
$referror = $cberror = "<h1>Data not Added</h1><br/><br/><h3>Please Follow The Instructions</h3>";
$urefdb = "INSERT INTO refdb(reftype,refname,refemail,refcnt,refdes) VALUES ('$refselect','$refname','$refemail','$refcnt','$refdes');";
include_once("db.php");
if ($refselect == "Select Type") die ("$referror");
if (empty ($refname)) die ("$referror");
if (mysql_query("$urefdb"))
{
echo "<h3>One Record Updated Successfully with the following Details </h3><br/>";
echo "Reference Type =$refselect <br/><br/>";
echo "Reference Name = $refname <br/><br/>";
echo "Reference E-Mail = $refemail <br/><br/>";
echo "Reference Description = $refdes <br/><br/>";
}
else
{
echo mysql_error();
}
?>
"refselect" data is coming from a drop down menu at the page now i want that as i add data through this form another form located at another page pic "refname" from database as i update "refdb" that drop down menu pick data accordingly
what to do now ?
You have to fill the dropdown menu on that another page using MySQL select like:
$request = mysql_query("SELECT refselect FROM refdb");
then iterate through all the results to fill your combobox:
echo "<SELECT>"; while ($drow = mysql_fetch_assoc($request)) { echo "<OPTION>" . $drow['refselect'] . "</OPTION>"; } echo "</SELECT>";
Or something like this
精彩评论