php - CodeIgniter select dropdown box with for loop -


i try create loop select box select time start 8.00 , increasing continusly matter found solution creating loop time incremented 15 minutes put code under array shows 1 time use var_dump($timeinoption) shows correctly as

array (size=1)   '8 . 0' => string '8 . 0' (length=5)  array (size=1)   '8 . 15' => string '8 . 15' (length=6)  array (size=1)   '8 . 30' => string '8 . 30' (length=6)  array (size=1)   '8 . 45' => string '8 . 45' (length=6)  array (size=1)   '9 . 0' => string '9 . 0' (length=5 

but codeignaiter select box not work;

form_dropdown('timein',$timeinoption,'8.30'); 

it shows 1 time on select box

echo form_label('time start','timestart');  ($i = 8; $i <= 17; $i++) {   ($j = 0; $j <= 45; $j+=15)   {     //inside inner loop     $opti= $i.' . '. $j;     $timeinoption=array($opti=>$opti) ;     }   //inside outer loop   }  echo form_dropdown('timein',$timeinoption,'8.30');        ?> 

you overwriting array on each loop

$timeinoption=array($opti=>$opti); 

so there 1 value in array.

try changing

$timeinoption[$opti]= $opti; 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -