Jump to content

Return DB search to table


griffiths1983
 Share

Recommended Posts

Hello. I am one of the millions of noobs out there. I have a script designed to look up database and return search results to a table. The page however is blank so nothing is being output at all. Even the source is empty when I look at it.

 

So the script starts with a simple index page to enter the search term and then submit. The search.php page then has the following parsed into the browser url = search.php?query=death&submit=Search

 

I have tried searching google for all sorts of reasons for blank pages but none appear to help as they all appear to be unrelated.

 

the script i am using on the search page is below, I want to learn so some pointers would be useful please.

<?php
    mysql_connect("localhost", "user", "password") 
    mysql_select_db("db") or die(mysql_error());

    $query = $_GET['query'];
    $min_length = 1;
     if(strlen($query) >= $min_length)
     {
        $query = htmlspecialchars($query);
        $query = mysql_real_escape_string($query); 
      echo "<table border='0' width='300' align='center'>";
                echo "<tr align='center' bgcolor='#002C40' >
                <td height='35px' width='150px'>Title</td> 
                <td>Author</td></tr>";    
   $raw_results = mysql_query("SELECT * FROM avathar15 WHERE 
(`user` LIKE '%".$query."%') OR (`alliance` LIKE '%".$query."%')");
        if(mysql_num_rows($raw_results) > 0)
        {
            while($results = mysql_fetch_array($raw_results))
            {
             echo "<tr align='center' bgcolor='#0f7ea3'>
             <td height='25px'>".$results['title']."</td>
            <td>".$results['text']."</td></tr>" ;
            }
         
        }
        else{
            echo "<tr align='center' bgcolor='#6C0000'>
           <td colspan='2' height='25px'>No results</td>
            <tr>";   
             echo "</table>"; 
        }  
    }
    else{
        echo "Minimum length is ".$min_length;
    }
?>
Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.