Page 1 of 1
Storing Drop Down Options
Posted: Tue Jan 25, 2011 6:55 am
by sockpuppet
Anyone got a nifty way to store drop down box variables.
I'm thinking that either the usual one mysql table per drop down (lots of tables!) or doing something like:
id,
drop_down_name, // the id of the drop downn
drop_down_value, // the value returned by the input
drop_down_display, // the text to display
drop_down_default, // the default selected option
and just calling the options as I need them into an array.
Anyone else found a good way of dealing with drop downs and storing the variables for them?
Re: Storing Drop Down Options
Posted: Tue Jan 25, 2011 7:24 am
by raj23
Hi bro,
You can use the following coding it'll be useful for you.
<?php
if ($_SERVER['REQUEST_METHOD']!= 'POST')
{
$rowsPerPage = $_post['choice'];
echo
'<form name="choice" method="post" action="post">
<select name="choice">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<input type="submit" name="choice" value="submit"/>
</form>';}?>
Drupal web developer
Re: Storing Drop Down Options
Posted: Tue Jan 25, 2011 7:40 am
by sockpuppet
I think you've got the wrong end of the stick
I'm after how to store the values sensibly in a database. A lot of the drop downs I use are dynamic so storing them in a database is the only way, just wondering what approach people favoured the multi_tables approach or the single table with an extra variable approach.
Re: Storing Drop Down Options
Posted: Tue Jan 25, 2011 10:49 am
by AbraCadaver
sockpuppet wrote:I think you've got the wrong end of the stick
I'm after how to store the values sensibly in a database. A lot of the drop downs I use are dynamic so storing them in a database is the only way, just wondering what approach people favoured the multi_tables approach or the single table with an extra variable approach.
It depends on how many and if they are all related. What do these dropdowns represent. Normally I use 1 table for each dropdown to hold the possible values, but the actual selected data that the user submits will be held in some other table depending on the data.
Re: Storing Drop Down Options
Posted: Tue Jan 25, 2011 2:40 pm
by sockpuppet
Nothing much just
UK => United Kingdom
US => USA
Style data. Just thinking it was a neater way than having one table per drop down.
Re: Storing Drop Down Options
Posted: Tue Jan 25, 2011 2:50 pm
by AbraCadaver
sockpuppet wrote:Nothing much just
UK => United Kingdom
US => USA
Style data. Just thinking it was a neater way than having one table per drop down.
I think your approach sounds good. Try it out and see how you like it.