嘿所以我是PHP / HTML的新手,但在我的代码下面我没有错误。我从数据库服务器读取执行正确的查询然后将我的数据从查询存储在Combobox aka列表中。我希望能够获得用户选择的项目的值。但我最终得不到任何结果。我尝试通过输入以下内容来检查:
echo $search;?>
<br>First shift Super:
<select name="search"> <!-- COMBO Box -->
<?php foreach($data as $i=>$rows): ?>
<!-- AMOUNT(PROID), THEN FILL WITH THE CONTENT(PRONAME)-->
<option value="<?=$rows['PROID']?>"><?=$rows['PRODNAME']?></option>
<?php endforeach; ?>
</select>
<!-- TESTING For getting selected value BELOW-->
<?php $search = $_POST['search'];//$search holds the selected value?
echo $search; //Nothing appears
$query2 = "SELECT * FROM PRODUCTS WHERE PRODNAME = '$search'";
$stid2 = oci_parse($dot, $query2); //turns this into something database can understand
oci_execute($stid2);//executes the query
$data2 = array();
//$length equals the # of rows/Tuples returned by query
//oci_fetch_all stores database info into $data
$length2 = oci_fetch_all($stid2, $data2, null, null, OCI_FETCHSTATEMENT_BY_ROW);
//http://php.net/manual/en/function.oci-fetch-all.php
$firstRow = $data2[0];//now holds data from table?>
<!-- TESTING For getting selected value ABOVE-->
Phone #: <input type='phone' name='phone'></br>
<br> On Call:<select name="name"> <!-- COMBO Box -->
<?php foreach($data2 as $i=>$rows): //PRODNAME Display is EMPTY ?>
<!-- AMOUNT(PROID), THEN FILL WITH THE CONTENT(PRONAME)-->
<option value="<?=$rows['PROID']?>"><?=$rows['PRODNAME']?></option>
<?php endforeach; ?>
</select>
答案 0 :(得分:0)
我结束了使用$ search = $ _ POST [“搜索]现在我的选定值将被存储到$ search中。点击按钮。