savagenoob Posted December 12, 2010 Share Posted December 12, 2010 I have a script that displays a certain result set, the row I am concerned about is called 'endonum'. Some rows will have the same number in this field. Is there a way to only show 1 result with the same number in this field. The array will be like '1, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5' and so on, but I just want to display 1 of them, not all. Kinda confusing but maybe someone gets it. Here is the code. <?php $selectendo = mysql_query("SELECT * FROM endorse WHERE agency = '$agency' AND finalized = 'No'")or die(mysql_error()); while($showendo = mysql_fetch_array($selectendo)) { $endonumber = $showendo['endonum']; ?> <li><a href="viewendo.php?endonum=<?php echo $endonumber;?>">Endorsement Number:<?php echo $endonumber . " Date: " . $showendo['date'];?></a></li> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/221369-mysql-loop-into-array-question/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 12, 2010 Share Posted December 12, 2010 Are the $showendo['date'] vales the same when 'endonum' has the same value or what do you want to use for $showendo['date'] when you have several 'endonum' with the same value? Quote Link to comment https://forums.phpfreaks.com/topic/221369-mysql-loop-into-array-question/#findComment-1146057 Share on other sites More sharing options...
savagenoob Posted December 12, 2010 Author Share Posted December 12, 2010 Yeah the date on all of them will be identical as well. Quote Link to comment https://forums.phpfreaks.com/topic/221369-mysql-loop-into-array-question/#findComment-1146058 Share on other sites More sharing options...
PFMaBiSmAd Posted December 12, 2010 Share Posted December 12, 2010 Using DISTINCT in the query would probably solve it. It removes duplicate rows from the result set. You would need to select only those columns you need, rather than * Quote Link to comment https://forums.phpfreaks.com/topic/221369-mysql-loop-into-array-question/#findComment-1146060 Share on other sites More sharing options...
savagenoob Posted December 12, 2010 Author Share Posted December 12, 2010 Oh, thats sweet. You da man... Thanks Quote Link to comment https://forums.phpfreaks.com/topic/221369-mysql-loop-into-array-question/#findComment-1146061 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.