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 Link to comment https://forums.phpfreaks.com/topic/130714-solved-remove-repetitions/ 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? Link to comment https://forums.phpfreaks.com/topic/130714-solved-remove-repetitions/#findComment-678334 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 Link to comment https://forums.phpfreaks.com/topic/130714-solved-remove-repetitions/#findComment-678336 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. Link to comment https://forums.phpfreaks.com/topic/130714-solved-remove-repetitions/#findComment-678374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.