$username Posted June 20, 2007 Share Posted June 20, 2007 Hello All, I am working on some output from an MYSQL table to auto display the info from a table. Here is my code. $sql0 = "SELECT * FROM userlogin ORDER BY `ID` DESC LIMIT 0,1"; $sql1 = "SELECT * FROM userlogin ORDER BY `ID` DESC LIMIT 1,2"; $query0 = mysql_query($sql0); $query1 = mysql_query($sql1); $row0 = mysql_fetch_array($query0); $row2 = mysql_fetch_array($query2); Every time I go over my display query limit I have to add new ones. How would I create something so it will automatic pulls from the database table and automatically shows in my drop down box the new fields I add to the table. This is the part that is for the drop down box. <option value="<?echo $row0['username']; ?>"><?echo $row0['username']; ?></option> <option value="<?echo $row1['username']; ?>"><?echo $row1['username']; ?></option> I am new at this so let me know if there is something I can do different. Thank you Link to comment https://forums.phpfreaks.com/topic/56459-dynamic-display-from-mysql-in-an-aray/ Share on other sites More sharing options...
trq Posted June 20, 2007 Share Posted June 20, 2007 <?php $sql = "SELECT * FROM userlogin ORDER BY `ID` DESC"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo "<option value=\"{$row['username']}\">{$row['username']}</option>"; } } } ?> Link to comment https://forums.phpfreaks.com/topic/56459-dynamic-display-from-mysql-in-an-aray/#findComment-278854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.