簡體   English   中英

從php oracle數據庫填充選擇列表

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM