bamfon Posted February 15, 2011 Share Posted February 15, 2011 Could someone help me I really dont know how to go about coding this, so i would be happy if someone could point me in the right way Well what I am trying to do is use mysql_num_rows to call up how many rows in the table. The using how many rows, use a menu with the numbers of rows that are in the table ex below mysql_num_rows gets 5 rows so menu is <select name="order" > <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> </select> Link to comment https://forums.phpfreaks.com/topic/227695-mysql_num_rows-and-select-menu/ Share on other sites More sharing options...
requinix Posted February 15, 2011 Share Posted February 15, 2011 Don't use mysql_num_rows() - run an actual query. SELECT COUNT(*) FROM table Then a simple for loop. Link to comment https://forums.phpfreaks.com/topic/227695-mysql_num_rows-and-select-menu/#findComment-1174333 Share on other sites More sharing options...
cyberRobot Posted February 15, 2011 Share Posted February 15, 2011 You can try something like this: <?php ... $numRows = mysql_num_rows($result); if($numRows > 0) { echo '<select name="order">'; for($i=1; $i<=$numRows; $i++) { echo "<option value='$i'>$i</option>"; } echo '</select>'; } ?> Note that the code is untested. Link to comment https://forums.phpfreaks.com/topic/227695-mysql_num_rows-and-select-menu/#findComment-1174335 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.