Daney11 Posted February 8, 2008 Share Posted February 8, 2008 Hey guys. Im using <select class="forminput" name="result_hours"><?php for ($i=0; $i<=24; $i++) { echo "<option value=\"$i\""; if ($i==$sel_hours) echo " selected"; echo ">$i</option>"; } ?></select> It returns the correct values 1 2 3 4 5 etc But on the single digits i want it to return 01 02 03 04 05 etc how do i go about doing this? cheers. Link to comment https://forums.phpfreaks.com/topic/90071-solved-drop-down/ Share on other sites More sharing options...
Sulman Posted February 8, 2008 Share Posted February 8, 2008 you need to start treating the number as a string. Try adding this in to your for loop: if($i<10) { $val="0$i"; } else { $val=$i; } Link to comment https://forums.phpfreaks.com/topic/90071-solved-drop-down/#findComment-461834 Share on other sites More sharing options...
Daney11 Posted February 8, 2008 Author Share Posted February 8, 2008 thanks Link to comment https://forums.phpfreaks.com/topic/90071-solved-drop-down/#findComment-461838 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.