Forum Moderators: coopster
below is the function where i display data in combo box
function selectEquipType()
{
if (!is_resource($this->mysql_resource_combo))
die ("User doesn't supply any valid mysql resource after executing query result". mysql_error());
// load data into combo box
echo "<form name = \"queryEquipTypeForm\" method = \"post\" action = \"equip_onLoan.php?typeID = $typeID\">";
echo "<select name=\"equipTypeCombo\">\n";
//Now fill the table with data
while ($row = mysql_fetch_array($this->mysql_resource_combo))
{
$type = $row['description'];
$typeID = $row['assetTypeID'];
echo "<option value <?php $typeID?>$type</option>\n";
}
echo "</select>\n";
echo "<input type=\"submit\" value=\"Query\" name=\"Query\" onsubmit=\"searchEquipType(\"queryEquipTypeForm\", \"equipTypeCombo\")\">";
return $eTypeID;
}
i have this piece of code on one php page:
function selectEquipType()
{
if (!is_resource($this->mysql_resource_combo))
die ("User doesn't supply any valid mysql resource after executing query result". mysql_error());
// load data into combo box
echo "<form name = \"queryEquipTypeForm\" method = \"post\" action = \"equip_onLoan.php\">";
echo "<select name=\"equipTypeCombo\">\n";
//Now fill the table with data
while ($row = mysql_fetch_array($this->mysql_resource_combo))
{
$type = $row['description'];
$typeID = $row['assetTypeID'];
echo "<option value <?php $typeID?>$type</option>\n";
}
echo "</select>\n";
echo "<input type=\"submit\" value=\"Query\" name=\"Query\">";
echo "combo box data is ". $_POST['equipTypeCombo'];
return $_POST['equipTypeCombo'] ;
whereas this piece of code on another php page (equip_onLoan.php):
// display all the Equipment type onto combox
$res_combo = mysql_query("select * from ims_assetType order by description asc");
$prg->mysql_resource_combo = $res_combo;
$eType = $prg->selectEquipType();
echo "combo box data is in equip on loan page". $eType;
i would like the selected item in combo box to be captured and passed into sql statement to retrieve the data. how do i go about it, thanks.
This code is not necessary:
echo "combo box data is ". $_POST['equipTypeCombo'];return $_POST['equipTypeCombo'] ;
There is no reason to return anything from the $_POST array as it is a superglobal [us2.php.net] and is therefore automatically available outside the function without returning the value.
On the first time the page is loaded, if you set your error reporting to E_ALL this should be giving you a notice for that echo statement and the return statement (undefined index).
If you don't have your error_reporting set to E_ALL, add this line at the top of the script
error_reporting(E_ALL);
but there is one strange thing...e.g. the item "voice recorder" is selected inside the combo box. $_POST[equipTypeCombo] only retrieves "voice" but not "voice recorder". any idea why is this so? the same goes to other string when there is a space in between...like e.g. digital camera