DieterDaems Posted October 22, 2009 Share Posted October 22, 2009 For now this is all i got. Because i have no idea, how to prevent outputting the same value. And still continueing the loop. Can anyone help me, or point me in the right direction? with friendly greetings, Dieter $myDb->connect(); $sql = "SELECT * FROM `winelist`, `winemakers` WHERE (`winelist`.`winemakerid` = `winemakers`.`id`) ORDER BY winecountry, winetype, winename_sub, wineyear "; $query = mysql_query($sql) or die("Query failed: " . mysql_error()); $result = mysql_fetch_array($query); $myDb->close(); echo "<h3 class='menuheader expandable'>Per Winemaker</h3>"; echo "<ul class='categoryitems'>"; while ($result = mysql_fetch_array($query)){ $makername = htmlentities($result['makername']); echo "<li><a href='wines.php?winemaker='$makername'>$makername</a></li>"; } echo "</ul>"; Link to comment https://forums.phpfreaks.com/topic/178657-solved-qhow-do-i-prevent-ouputting-the-same-value-in-a-while-loop/ Share on other sites More sharing options...
jon23d Posted October 22, 2009 Share Posted October 22, 2009 Use DISTINCT or GROUP to make your life easier. Link to comment https://forums.phpfreaks.com/topic/178657-solved-qhow-do-i-prevent-ouputting-the-same-value-in-a-while-loop/#findComment-942377 Share on other sites More sharing options...
purpleshadez Posted October 22, 2009 Share Posted October 22, 2009 Use DISTINCT or GROUP to make your life easier. This would be a slight mod of your SQL statement $sql = "SELECT * FROM `winelist`, `winemakers` WHERE (`winelist`.`winemakerid` = `winemakers`.`id`) GROUP BY fieldName ORDER BY winecountry, winetype, winename_sub, wineyear "; Link to comment https://forums.phpfreaks.com/topic/178657-solved-qhow-do-i-prevent-ouputting-the-same-value-in-a-while-loop/#findComment-942432 Share on other sites More sharing options...
DieterDaems Posted October 22, 2009 Author Share Posted October 22, 2009 thx Link to comment https://forums.phpfreaks.com/topic/178657-solved-qhow-do-i-prevent-ouputting-the-same-value-in-a-while-loop/#findComment-942440 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.