Need help with Dropdown list

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hwmetzger
Forum Commoner
Posts: 25
Joined: Fri Jun 12, 2009 1:11 pm

Need help with Dropdown list

Post by hwmetzger »

I have a drop down list in my program that is being populated by values from mySQL and a "Submit" button. The trouble I am running into is how do I assign the selected value in the drop down to a variable?

Thanks guys!
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Need help with Dropdown list

Post by andyhoneycutt »

Please post the code in question (in

Code: Select all

tags).

-Andy
hwmetzger
Forum Commoner
Posts: 25
Joined: Fri Jun 12, 2009 1:11 pm

Re: Need help with Dropdown list

Post by hwmetzger »

Code: Select all

 
<tr>ect name="storenumber">
<?if(isset($store_number['store1'])){?><option value="<?=$store_number['store1'];?>"><?=$store_number['store1'];?></option><?}?>
<?if(isset($store_number['store2'])){?><option value="<?=$store_number['store2'];?>"><?=$store_number['store2'];?></option><?}?>
<?if(isset($store_number['store3'])){?><option value="<?=$store_number['store3'];?>"><?=$store_number['store3'];?></option><?}?>
</select>
<tr>
<tr>
<tr class="header">
    <td colspan=2 align="center" class="header"><input type="submit" value="store"></td>
    
</tr>
</table>
<input type="hidden" name="store" value="2">
<?
if(isset($_REQUEST['store']))
{
$report = $_GET['storenumber'];
echo $report;
?>
 
 
 
 
 
 
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Need help with Dropdown list

Post by andyhoneycutt »

It sounds like you're asking only how to make any option selected by default in a drop-down? If that's the case:

Code: Select all

<select name="something">
  <option value="some_value" selected="selected">Blah Blah Blah</option>
  <option value="other_value">Blah2 Blah2 Blah2</option>
</select>
-Andy
hwmetzger
Forum Commoner
Posts: 25
Joined: Fri Jun 12, 2009 1:11 pm

Re: Need help with Dropdown list

Post by hwmetzger »

Never mind, I figgured it out.
Post Reply