lilwing Posted July 16, 2008 Share Posted July 16, 2008 Not sure how to fix this problem... been cracking at it for a half hour. <?php $query = mysql_query('SELECT * FROM hyperlinks WHERE Category="primary" ORDER BY LinkOrder ASC') or die(mysql_error()); while($row = mysql_fetch_array($query)) { $primaryHREF = $row['ID']; } $query = mysql_query('SELECT * FROM hyperlinks WHERE Category="primary" ORDER BY LinkOrder ASC') or die(mysql_error()); while($row = mysql_fetch_array($query)) { $primaryName = $row['Name']; } echo ('<li><a href="'.$primaryHREF.'">'.$primaryName.'</a>'); ?> Link to comment https://forums.phpfreaks.com/topic/114948-variables-in-while-clause-trouble/ Share on other sites More sharing options...
sader Posted July 16, 2008 Share Posted July 16, 2008 does this help? <?php $query = mysql_query('SELECT * FROM hyperlinks WHERE Category="primary" ORDER BY LinkOrder ASC') or die(mysql_error()); while($row = mysql_fetch_array($query)) { $primaryName = $row['Name']; $primaryHREF = $row['ID']; echo ('<li><a href="'.$primaryHREF.'">'.$primaryName.'</a></li>'); //or just //echo ('<li><a href="'.$row['ID'].'">'.$row['Name'].'</a></li>'); } ?> if it's still crashes try $query = mysql_query('SELECT * FROM hyperlinks WHERE Category="primary" ORDER BY LinkOrder ASC LIMIT 25') or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/114948-variables-in-while-clause-trouble/#findComment-591185 Share on other sites More sharing options...
lilwing Posted July 16, 2008 Author Share Posted July 16, 2008 That worked. I changed it a little though. Now I have a horrible loop problem. <?php $query = mysql_query('SELECT * FROM hyperlinks WHERE Category="primary" ORDER BY LinkOrder ASC') or die(mysql_error()); while($row = mysql_fetch_array($query)) { while($row[Category] = 'primary') { $primaryName = $row[Name]; $primaryHREF = $row [hrEF]; while($row[Category] = 'secondary') { $primaryCategory = $row['PrimaryCategory']; $secondaryName = $row['Name']; $secondaryHREF = $row['HREF']; echo ('<li class="off"><a href="'.$primaryHREF.'">'.$primaryName.'</a>'); if($row[PrimaryCategory] != 0) { echo ('<ul>'); echo ('<li><a href="'.$secondaryHREF.'"></a>'.$secondaryName.'</li>'); echo('</ul>'); } echo ('</li>'); } } } ?> Link to comment https://forums.phpfreaks.com/topic/114948-variables-in-while-clause-trouble/#findComment-591233 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.