I have a simple table (called 'quotes') in a database (called
'stampin').  The table has four fields:
id (auto-increment and not used in display)
quote
author
keywords


What should happen is the user should enter a word in the search box
and it should check the 'keywords' field in the 'quotes' database.
When the word from the search matches a keyword, it should display the
quote ('quote') and then, on the next line, the author ('author'). 

Right now, it's displaying all the information in the database before
a search is performed.

Can someone please help fix it and explain what I am doing wrong? My
code is below (I took the connect info out so I'm not giving out the
login & password for my database, but the info in it is okay).

Thank you SO much.

<?php
mysql_connect("server","login","password") or die ("Please contact
website administrator");
mysql_select_db("stampin");
if($HTTP_POST_VARS["keywords"]) {
        $result=mysql_query("SELECT * FROM quotes ".
                "WHERE keywords LIKE \"%".
                addslashes($HTTP_POST_VARS["keywords"])."%\"");
        while($row=mysql_fetch_array($result)) {

        echo "<b>Quote:</b> ".$row["quote"]. "<br>".

        "<b>Author:</b> ".$row["author"]."<p>";
        }

}

?>









The php_mysql group is dedicated to learn more about the PHP/MySQL web database 
possibilities through group learning.  
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php_mysql/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to