你好,第一次这样做,基本上我很困惑如何重新填充数据库中的文本框。从sql使用下拉列表填充文本字段jquery
我目前的问题是,基本上我的数据库'USER'和'STATISTICS'中有两个表。 目前工作的是我的代码正在'USER'表中查找'User_ID'的值,并在下拉列表中填充值。
我想从没有为文本字段填入对应于从数据库中查找的“USER_ID” EG“goal_scored”这些价值观,“帮助”,“clean_sheets”等
我非常困惑我已经查询了各种不同的问题,但无法找到即时寻找。
<?php
$link = mysql_connect("localhost","root","");
mysql_select_db("f_club",$link);
$sql = "SELECT * FROM user ";
$aResult = mysql_query($sql);
?>
<html>
<body>
<title>forms</title>
<link rel="stylesheet" type="text/css" href="css/global.css" />
</head>
<body>
<div id="container">
<form action="update.php" method="post">
<h1>Enter User Details</h1>
<h2>
<p> <label for="User_ID"> User ID: </label> <select id="User_ID" id="User_ID" name="User_ID" >
<br> <option value="">Select</option></br>
<?php
$sid1 = $_REQUEST['User_ID'];
while($rows=mysql_fetch_array($aResult,MYSQL_ASSOC))
{
$User_ID = $rows['User_ID'];
if($sid1 == $id)
{
$chkselect = 'selected';
}
else
{
$chkselect ='';
}
?>
<option value="<?php echo $id;?>"<?php echo $chkselect;?>>
<?php echo $User_ID;?></option>
<?php }
?>
I had to put this in because everytime I have text field under the User_ID it goes next to it and cuts it off :S
<p><label for="null"> null: </label><input type="text" name="null" /></p>
<p><label for="goal_scored">Goal Scored: </label><input type="text" name="Goal_Scored" /></p>
<p><label for="assist">assist: </label><input type="text" name="assist" /></p>
<p><label for="clean_sheets">clean sheets: </label><input type="text" name="clean_sheets" /></p>
<p><label for="yellow_card">yellow card: </label><input type="text" name="yellow_card" /></p>
<p><label for="red_card">red card: </label><input type="text" name="red_card" /></p>
<p><input type="submit" name="submit" value="Update" /></p></h2>
</form>
</div>
</body>
</html>
如果任何人都可以有助于理解才能到下一个阶段,将不胜感激感谢X
嗯......你需要告诉服务器哪个用户被选中。要么执行AJAX请求,要么检索数据直接将其放入文本字段,要么发送表单到服务器,并让PHP脚本检索相应的值。 – 2013-03-09 15:49:25