我有一个HTML文本框,我希望它从mysql数组中的值自动完成文本框。
Supplier:
<input type="text" name="supplier" id="supplier" autocomplete="off" required style="position:absolute; left:200px" />
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("purchasing", $con);
$array=mysql_query("SELECT `supplier` FROM existing_material");
答案 0 :(得分:1)
你可以使用html5
来做到这一点 <input name="frameworks" list="frameworks" />
<datalist id="frameworks">
<?php
$query = "";
while($row = mysql_fetch_assoc($query)){
?>
<option value="<?php echo $row['yourfeild']; ?>">
<?php } ?>
</datalist>
示例代码:
<input name="frameworks" list="frameworks" />
<datalist id="frameworks">
<option value="MooTools">
<option value="Moobile">
<option value="Dojo Toolkit">
<option value="jQuery">
<option value="YUI">
</datalist>