Bricktop Posted October 30, 2008 Share Posted October 30, 2008 Dear all, I have a very simple PHP script as follows: $sql = mysql_query("SELECT * FROM personaldata ORDER BY surname ASC"); while ($a = mysql_fetch_array($sql)) { $content .= ''.stripslashes($a['firstname']).'<br />'; $content .= ''.stripslashes($a['surname']).'<br />'; $content .= ''.stripslashes($a['email']).''; } echo $content; My problem is, sometimes some of the data is repeated because the same name and email address has been stored in the database. I would like the above script to show all the data but if it finds a repetition to not display it. I hope the above makes sense and you are able to help! Thanks Quote Link to comment Share on other sites More sharing options...
Mchl Posted October 30, 2008 Share Posted October 30, 2008 Wouldn't more logical approach be to remove duplicate entries from database? Quote Link to comment Share on other sites More sharing options...
zenag Posted October 30, 2008 Share Posted October 30, 2008 use distinct(name) or group by name in select statement Quote Link to comment Share on other sites More sharing options...
Bricktop Posted October 30, 2008 Author Share Posted October 30, 2008 Thanks zenag, got it working brilliantly with DISTINCT - forgot all about the DISTINCT syntax! Thanks also for your reply Mchlm. Quote Link to comment 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.