Jump to content

mysql_num_rows and select menu


bamfon

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.