Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post

    problem with search engine

    i have this code in my search engine and for some reason it just outputs "search returned no results" on everything even when it does return results

    if(!empty($row)){
    echo "<center>No Results found for your search: <em>$q</em></center>";
    }
    -----------------------------
    the complete code is...
    -----------------------------
    <?php
    if(isset($q)){
    $aa = mysql_connect("localhost", "root", "password");
    $db = mysql_select_db("search",$aa);
    $sql_select = "SELECT * FROM search WHERE keywords LIKE '%$q%'";
    $result = mysql_query($sql_select) or die ("Queryproblem: " . mysql_error());

    while ($row = mysql_fetch_array($result)) {
    echo "<table width='97%' align='center' border='0' bgcolor='#FFFFFF'>";
    echo "<tr>";
    echo "<td background='ed.gif'><span class='style2'>&nbsp;&nbsp;&nbsp;&nbsp&nbsp;<a href='$row[2]' class='search'><font face='arial' size='2'><b>$row[0]</font></b></a> </span></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td><span class='style44'><font face='arial' size='2' color='#000099'>$row[1]</font></span></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td> <span class='style8'>&nbsp;<a href='$row[2]' class='search2'><font face='arial' size='2'><b>$row[4]</font></b></a></span></td>";
    echo "</tr>";
    echo "</table>";
    echo "<br>";
    }
    if(!empty($row)){
    echo "<font face='arial' size='3' color='navy'><center><b>No Results found for your search:</b> <em>$q</em></center></font>";
    }
    }
    ?>

  • #2
    New Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php 
    if(isset($q)){
    $aa mysql_connect("""""");
    $db mysql_select_db("database",$aa);
    $sql_select "SELECT * FROM table WHERE thing LIKE '%$q%'";
    $result mysql_query($sql_select) or die ("Queryproblem: " mysql_error());

    if (
    mysql_num_rows($result) > 0) {

        while (
    $row mysql_fetch_array($result)) {
        print 
    $row[0];
        }; 
    //end fetch

        
    } else {
            
    // no rows returned, no search
            
    echo "<font face='arial' size='3' color='navy'><center><b>No Results found for your search:</b> <em>$q</em></center></font>";
        }
    }; 
    // end if q
    ?>
    that worked for me


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •