[英]Populate a select list from php oracle database
我试图从下面的PHP脚本连接到Oracle数据库,以填充一个下拉列表,但是该脚本不起作用。
谁能看到一个问题? 非常感谢!
$conn = oci_connect('username', 'password', 'host');
$stid = oci_parse($conn, 'select product_id, product_name from product order by product_id');
oci_execute($stid);
$query = "select product_id, product_name from product order by product_id";
$res = mysql_query($stid);
echo "<select name = 'Product'>";
while (($row = mysql_fetch_row($res)) != null)
{
echo "<option value = '{$row['product_id']}'";
if ($selected_product_id == $row['product_id'])
echo "selected = 'selected'";
echo ">{$row['product_name']}</option>";
}
回显“”;
为什么使用mysql_ *询问oracle数据库? 我认为要使用的正确函数是oci_execute
$res = mysql_query($stid);
代码中的上一行用于查询MySQL数据库,而不是Oracle。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.