View Single Post
Old 05-07-2009, 04:32 PM   #1 (permalink)
Kay1021
The Contributor
 
Join Date: May 2008
Posts: 36
Thanks: 5
Kay1021 is on a distinguished road
Help Removing Search Results from drop down

Hi i had a little question I was wondering someone might be able to answer. Right now i have a code that searches through the database and outputs results based on the search...then below I have a drop down menu that grabs data from the database to fill it. It works perfectly I was just wondering if there was a way that I could eliminate the first results from showing up in the drop down menu. I hope that made sense...i'll post the code that I have....any help is greatly appreciated.

PHP Code:
        /* Connect to database */
        
$con=mysql_connect(localhost"root""root");
        
mysql_select_db("db");
        
        if (!
$con)
                  {
             die(
'Could not connect: ' mysql_error());
              }
    
            
$sql "SELECT DISTINCT cat_name, postcode
                        FROM postalcode
            WHERE postcode = '
$postcode'
            AND status='sold'"
;

            
$qry mysql_query($sql);
        
            if (
mysql_num_rows($qry) > 0) {
                while (
$rs mysql_fetch_assoc($qry)) {
                         
$cat_name $rs['cat_name'];
                         
$postcode $rs['postcode'];
                         echo 
$rs['cat_name'] . '<br/>';
                }
            } else {
                print 
'no result found';
            }
            
            print 
'<form method="POST" action="index.php?ID=15">';
        
            
$query="SELECT DISTINCT cat_name 
                        FROM category 
                        GROUP BY cat_name"
;
                                
            
$result mysql_query ($query);
            echo 
"<select name=cat_name value=' '>";
            echo 
"<option value=''>View Available               
                        Categories</option>"
;
            while(
$nt=mysql_fetch_array($result))
                            {
                       echo 
"<option value=''>$nt[cat_name]</option>";
                }
            echo 
"</select><br/>";
                    
    
            print 
' <input type="submit" value="Contact Us for More 
                                  Information">
            </form>'


Thanks so much
Kay1021 is offline  
Reply With Quote