php动态下拉菜单从数据库中选择值

时间:2010-01-04 16:05:31

标签: php

我使用以下代码将数据插入mysql数据库

<?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”数据来自页面的下拉菜单现在我想要,因为我通过这个表单添加数据另一个表单位于另一个页面pic“refname”来自数据库,因为我更新“refdb”下拉菜单相应地选择数据

现在该怎么办?

1 个答案:

答案 0 :(得分:0)

要通过更改选择的值来更新其他表单的值,您需要了解javascript的“onchange”事件。