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> Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.