我试图在我的HTML网站中使用PHP脚本。当我运行它时,php脚本正在按预期工作。我的PHP脚本:
<?php
mysql_connect("localhost","demo","123abc");
mysql_select_db("demo");
$sql=mysql_query("SELECT vorname FROM users");
if(mysql_num_rows($sql)){
$select= '<select name="select">';
while($rs=mysql_fetch_array($sql)){
$select.='<option value='.$rs['vorname'].'>'.$rs['vorname'].'</option>';
}
}
$select.='</select>';
echo $select;
?>
现在我想要的是在我的网站上的不同位置显示下拉列表。我的想法是仅在需要时插入php脚本。我的html部分:
<td>
<?php include 'http://localhost/Testsamples/test.php'; ?>
</td>
但这不起作用,我也不知道为什么。有人可以帮我吗?
谢谢
您不通过文件URL包含文件,必须使用系统文件路径:
<td>
<?php include '/path/to/Testsamples/test.php'; ?>
</td>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句