[英]Populate a select list from php oracle database
I am trying to connect to Oracle database from the following PHP script to populate a drop down list but the script doesn't work. 我试图从下面的PHP脚本连接到Oracle数据库,以填充一个下拉列表,但是该脚本不起作用。
Can anyone see an issue? 谁能看到一个问题? Many thanks!
非常感谢!
$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>";
}
echo ""; 回显“”;
Why are you using mysql_* to interrogate an oracle database?? 为什么使用mysql_ *询问oracle数据库? I think the right function to use is oci_execute
我认为要使用的正确函数是oci_execute
$res = mysql_query($stid);
The above line in your code is used to query a MySQL database,not Oracle. 代码中的上一行用于查询MySQL数据库,而不是Oracle。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.