View Single Post
Join Date: Jun 2008
Posts: 6
Reputation: bigbob is an unknown quantity at this point 
Solved Threads: 0
bigbob bigbob is offline Offline
Newbie Poster

Remov duplicates from array

 
0
  #1
Dec 4th, 2008
I hope someone can help I've been trying to sort this for hours.
I am trying to pull info from my database and display everything which I have done successfully, however I have duplicate records in my database due to records in different subcategories.
Anyway I want to display everything but only once and not display the duplicates.
At pres my code is this:
  1. <?php if(isset($_GET['alph'])){
  2. $alph = $_GET['alph'];
  3. $sql = "SELECT * FROM paid WHERE title LIKE '$alph%' ORDER by asc";
  4. $query = mysql_query($sql);
  5. while($data = mysql_fetch_array($query)){
  6. $desc = substr($data['description'],0,100);
  7. echo "<tr><td valign=\"top\">".$data['title']." ".$data['description']."</tr></td>";
  8. }}
  9. ?>
Now I have tryed DISTINCT in the sql statement and that didn't work and I have tryed using array_unique() eveywhere but to be honest I'm not exactly sure how to use array_unique() with mysql_fetch_array.
If someone could point me in the right direction it will save this hole in my wall getting any bigger as I feel I can do nothing but bash my head against it.

PLEASE HELP!!
Reply With Quote