Help me to solve this problem with php-form-db ..!?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mtibor
    New Member
    • Nov 2006
    • 1

    #1

    Help me to solve this problem with php-form-db ..!?

    Hello people,
    i have a form with 3 elements , 2 of those are option select and 1 is input text as follow :
    Code:
    <form method="post" action="search.php">
     
      <select name="search"> 
      <option value="">""</option> 
      <option value="fiat">fiat</option>
       <option value="hunday">hunday</option> 
       <option value="reno">reno</option> 
       <option value="toyota">toyota</option> 
       <option value="skoda">skoda</option> 
       <option value="audi">audi</option>
        </select> 
        
        <input type="text" name="search2" size=25 maxlength=25>
        
        <select name="search3"> 
      <option value="">""</option> 
      <option value="diesel">diesel</option>
       <option value="benzin">benzin</option> 
        </select> 
        
        <input type="Submit" name="Submit" value="Submit"> </form>

    The Php part that i have until now is :

    Code:
    mysql_connect("localhost","oooo","ooo"); 
        
    
    mysql_select_db("amaxadiko");
    
    $search=$_POST['search'];
    $search2=$_POST['search2'];
    $search3=$_POST['search3'];
    
    
    $result = mysql_query("SELECT * FROM auto WHERE company = '$search' AND model = '$search2' AND fuel = '$search3'");
    
    
    $numRows = mysql_num_rows($result);
    
    if( $numRows == "0" ){
    
    
    echo "No Results Found";
    
    } else {
    
    while($r=mysql_fetch_array($result))
    {    
      
       $company=$r['company'];
       $model=$r['model'];
       $price=$r['price'];
       $fuel=$r['fuel'];
          
       
     
       echo " Producer: $company<br>  Model: $model<br> Price: $price<br> Fuel: $fuel<br> <p>";
    }
    
    }

    So until now all right, just when one of those 3 elements of the form is EMPTY "" then am getting as result the echo " No results " .
    Par example, if is selected only in select SKODA, but the next imput text is EMPTY "" then to dont write "No results found" but to write the SKODAs that exist in database .
    How we can have this done ? By the use of several if's maybe ?
    ..am a newbie so i will apreciate very very much code-example on it .

    In any case am waiting to see your asnwers on the way to the solution of my prob. Plz Help !

    Thanks
Working...