mclard Posted June 30, 2008 Share Posted June 30, 2008 Hi, I have a mysql database containing 100 records, some of these records have a 'position' against them. Im trying to get the following result.... 1. A list containing 100 entries. 2. If li 1 has a 'position' against it, data is entered from the database, or it has default text, this is to carry on to li 100. What ive got so far follows $i = 1; if ($i<=100) { $SQL = "SELECT * FROM ws WHERE location ='$data' AND position ='$i'"; $result = mysql_query($SQL); while ($row=mysql_fetch_array($result)) { echo "<div><ul id='$i'>"; echo "<li id='$row[0]'>$row[4]</li>"; echo "</ul></div>"; } $i++; } else { echo "????"; } Thanks Quote Link to comment https://forums.phpfreaks.com/topic/112549-php-and-li/ Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 whats that displaying? Quote Link to comment https://forums.phpfreaks.com/topic/112549-php-and-li/#findComment-577987 Share on other sites More sharing options...
mclard Posted June 30, 2008 Author Share Posted June 30, 2008 Just a blank screen... Quote Link to comment https://forums.phpfreaks.com/topic/112549-php-and-li/#findComment-577992 Share on other sites More sharing options...
Lamez Posted June 30, 2008 Share Posted June 30, 2008 try this: <?php echo "<div><ul id='$i'>"; echo "<li id='".$row[0]."'>".$row[4]."</li>"; echo "</ul></div>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/112549-php-and-li/#findComment-578003 Share on other sites More sharing options...
mclard Posted June 30, 2008 Author Share Posted June 30, 2008 If i use $i = 1; if ($i<=100) { $SQL = "SELECT * FROM ws WHERE location ='$data' and position ='$i'"; $result = mysql_query($SQL); while ($row=mysql_fetch_array($result)) { if ($row[4] == '$i') { echo "<div><ul id='$i'><li id='$row[0]'>$row[4]</li></ul></div>"; } else { echo "<div><ul id='$i'></ul></div>"; } } $i++; } I get some output but not the right one... What i get in the page source is <div><ul id='1'></ul></div> <div><ul id='1'></ul></div> And what id hope to get is <div><ul id='1'><li></li></ul></div> <div><ul id='2'><li>2</li></ul></div> <div><ul id='3'><li></li></ul></div> <div><ul id='4'><li>4</li></ul></div> Thanks Quote Link to comment https://forums.phpfreaks.com/topic/112549-php-and-li/#findComment-578062 Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 you know that means each line is a whole new list, and each list only has 1 value? seems abit stupid, should make each line 1 item in the list. Quote Link to comment https://forums.phpfreaks.com/topic/112549-php-and-li/#findComment-578071 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.