Jump to content


Photo

searching arrays


  • Please log in to reply
3 replies to this topic

#1 witham

witham
  • Members
  • PipPipPip
  • Advanced Member
  • 86 posts

Posted 14 August 2006 - 08:29 PM

Can anyone please tell me if there is a way to search an array but only display unique entries even though duplicates may be there?



#2 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 14 August 2006 - 08:31 PM

http://uk.php.net/array_unique

#3 witham

witham
  • Members
  • PipPipPip
  • Advanced Member
  • 86 posts

Posted 14 August 2006 - 08:37 PM

thanks very much, thought there must be one

cheers!!

#4 witham

witham
  • Members
  • PipPipPip
  • Advanced Member
  • 86 posts

Posted 14 August 2006 - 09:24 PM

I am a little confused as to where to put the array_unique, could you help please:


<tr><td><b>Product Name:</b></td>

<!--put the query $sqlPRODNAME into the $result variable or display error if query fails-->

<?


$result  = mysql_query($sqlPRODNAME, $dblink)
	or die("<p>Error Processing Query</p><hr /><p>".mysql_error()."</p>\n");


// mysql_fetch_array fetches the results from the query a row at a time and populates the drop down box each time it's called
// the result is returned as an array that can be referenced either by field name or by it's index, "ALL" is hardcoded because
//it is always constant and allows the % query to be executed


echo '<td><select name="Equivalent">';
echo '<option value = "%"><b>ALL';

while ($row = mysql_fetch_array ($result)) 



// loop through the rows outputing them as select options
   {
	echo '<option value="' . $row["PRODEQUIV"] . '">' . $row["PRODEQUIV"] . "</option>";
   }	
?>
</select></td></tr>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users