简体   繁体   中英

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.

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?? I think the right function to use is oci_execute

$res = mysql_query($stid);

The above line in your code is used to query a MySQL database,not Oracle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM