Quote:
Originally Posted by Kay1021
Hey I really appreciate your help...
Your idea sounds good... unfortunately I haven't really worked with arrays too much...so this is kinda my first time and I'm not sure how to go about what your talking about. I tried the first idea but then i was having trouble trying to write the second query.
Sorry to be a pain
|
Pain? No, no pain, you should see what I do to the others around here with all the questions I ask....haha....
We will solve your issue. It's really not hard I know what you're trying to do...
In your first query, within your WHILE loop. You have this:
PHP Code:
while ($rs = mysql_fetch_assoc($qry)) {
$cat_name = $rs['cat_name'];
$postcode = $rs['postcode'];
echo $rs['cat_name'] . '<br/>';
}
Just add my extra line so it takes your cat_names and puts them into the array.
PHP Code:
while ($rs = mysql_fetch_assoc($qry)) {
$cat_name = $rs['cat_name'];
$postcode = $rs['postcode'];
$first_list[] = $cat_name;
echo $rs['cat_name'] . '<br/>';
}
Don't forget to create your array somewhere on the top of your code
with:
$first_list = array();
Then in your second query/output and your WHILE loop just check against the name and don't output if it's listed..
PHP Code:
while($nt=mysql_fetch_array($result))
{
if(!in_array($nt[cat_name],$first_list)) {
echo "<option value=''>$nt[cat_name]</option>";
}
}
This should work for you....