cheechm Posted May 9, 2008 Share Posted May 9, 2008 So I have this code mysql_num_rows($result) Say I get a number of 3. How do I echo "1" "2" "3", as I am using a select box. Link to comment https://forums.phpfreaks.com/topic/104940-solved-number-of-rows/ Share on other sites More sharing options...
pocobueno1388 Posted May 9, 2008 Share Posted May 9, 2008 Is this what you want? <?php $num = mysql_num_rows($result); echo '<select name="name">'; for ($i=1; $i<$num; $i++){ echo "<option>$i</option>"; } echo '</select>'; ?> Link to comment https://forums.phpfreaks.com/topic/104940-solved-number-of-rows/#findComment-537163 Share on other sites More sharing options...
munsiem Posted May 10, 2008 Share Posted May 10, 2008 I agree with the post before me, but are you asking for results 1, 2, and 3? This is how I would do so (if that is the question)... <? # Assuming you have already created the MYSQL Statement... $results = mysql_num_rows($mysql_result); echo("<select name='name_here'>"); while ($row = mysql_fetch_array($mysql_result)) { extract($row); echo("<option>$result_name</option>"); } echo("</select>"); ?> Link to comment https://forums.phpfreaks.com/topic/104940-solved-number-of-rows/#findComment-537288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.