PDA

View Full Version : need help with print_select_row


sodagod
05-22-2015, 04:20 PM
I am trying to get the selected option, but it always returns a number.

here is how i did it.



$array = array("option 1","option 2","option 3", "option 4","option 5");

print_select_row('title', 'get_select', $array);

$vbulletin->input->clean_array_gpc('p', array(
'get_select' => TYPE_ARRAY
));

$get_select = $vbulletin->GPC['get_select'];

echo $get_select;



this always results in the number of selected option, I also tried type_array as type_str and that didnt work.

kh99
05-22-2015, 04:47 PM
You can either use the number returned as a key to the array, so that the last line in your example might be:
echo $array[$get_select];


Or else you can make the array keys the values you want to get back, like:
$array = array("option 1" => "option 1","option 2" => "option 2","option 3" => "option 3","option 4" => "option 4","option 5" => "option 5");

I'd probably go with the first one if you can because if you use the same text you display you might run it to problems if it contains punctuation or something. If the choices are simple strings then it probably doesn't matter. Actually it might not matter either way, I guess it's just that I would do it the first way because I'm not sure.

sodagod
05-22-2015, 05:32 PM
first option works better, i tried that before, but I wasn't using the array value.