Dropdown menu in PHP

Hi,

Absolute beginner in php here. I am created a dropdown menu in my php code. Now I want to use the value selected by the user from the menu in the sql query that follows. How do I do that?

[php]<?php
function renderCrossConnectInventory ()
{

$patchpanels = array(
‘SM Fiber Patch - 110330)’ => 1,
‘SM Fiber Patch - 105831)’ => 2,
);

function generateSelect($name = ‘’, $options = array()) {
$html = ‘’;
foreach ($options as $option => $value) {
$html .= ‘’.$option.’’;
}
$html .= ‘’;
return $html;
}

print “

”;
$html = generateSelect(‘patchpanel’, $patchpanels);
echo “&nbsp&nbsp Select PatchPanel:”,$html;
print"

";

$query = “select a.name, b.string_value from Rack a LEFT JOIN RackSpace b ON a.id=b.rack where a.id=‘29’ and b.attr_id=‘10016’” ;

}
?>[/php]

thanks,
Shar.

Not sure if this was intentional, but i think you’ve got your functions messed up. You’ve got 1 embeded in the next one. should they be split?
[php]

<?php function renderCrossConnectInventory () { $patchpanels = array('SM Fiber Patch - 110330)' => 1, 'SM Fiber Patch - 105831)' => 2,); return $patchpanels; } function generateSelect($name = '', $options = array()) { $html .= ''; foreach ($options as $option => $value) { $html .= ''.$option.''; } $html .= ''; return $html; } print "

"; $html = generateSelect('patchpanel', renderCrossConnectInventory($patchpanels)); echo "&nbsp&nbsp Select PatchPanel:"; $html; print"

"; $query = mysql_query("select a.name, b.string_value from Rack a LEFT JOIN RackSpace b ON a.id=b.rack where a.id='29' and b.attr_id='10016'"); [/php] I don't know if that's how you intended it, but what i did notice is that you're not using the renderCrossConnectInventory function, but your trying to use $patchpanels, but the way your using it, it'll always be an empty variable.
Sponsor our Newsletter | Privacy Policy | Terms of Service