n00bie1221 n00bie1221 - 1 month ago 13
HTML Question

PHP Trying to get the value from a combobox

Hey so Im pretty new to PHP/HTML but In my code below I have No Errors. I read from a database server perform proper query then Store my data from the query in a Combobox aka list. I want to be able to obtain the value of the item the user selects. But i end up getting nothing. I attempt to check this by typing :

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>

Answer

i ended Up using $search=$_POST["search] now my selected value is being stored into $search upon the click of a button.