Re: distinct result using php & mysql

From: Date: Wed, 06 Dec 2000 03:18:00 +0000
Subject: Re: distinct result using php & mysql
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-28826@lists.php.net to get a copy of this message
> $resultrow[0] == apple, peach, orange, $resultrow[1] == apple, lemon, > kiwi , > how to I make sure that the second "apple " will not be printed? Not quite sure I got the test in the right place, since I don't understand the second query and field2... But this should pretty much do it for you. $printed = array(); > $query ="SELECT * FROM nom_table WHERE field1= 'x'"; > $result = mysql_query($query); > > $number = mysql_numrows($result); > > for ($g=0;$g<$number; $g++) > > { > > $field = mysql_result($result, $g, "field"); > > $filed = str_replace(",", " ", $field); > > $resultrow = explode (" ", $field); > > for ($i=0; $i<count($resultrow); $i++) > { #> if ($resultrow[$i]!=='') if ($resultrow[$i] != '' && !isset($printed[$resultrow[$i]])){ $printed[$resultrow[$i]] = true; > { > > $query2 = mysql_query ("SELECT COUNT(*) > FROM nom_table WHERE field LIKE '%$resultrow[$i]%' OR field2 LIKE > '%$resultrow[$i]%'"); > $y = mysql_fetch_array ($query2); > PRINT "&nbsp;<a > href='page.php3?search=$resultrow[$i]' > target=\"main\">$ADfont_style_current_vacancy_links > $resultrow[$i]</a>($no_skill_one[0] results)<br>\n"; > } > } > > } > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#28826) next »