Page 1 of 1

Searching database problem

Posted: Sun Nov 30, 2003 3:03 pm
by basdog22
hey,

just wondering....i have a databse of my record collection. its a simple one designed only so i can learn to use mysql with php. my question here regards sql. is there are way to search the whole table or several tables (the whole database) for a search phrase entered by the user? the way i understand it now, i will have to provide a drop down menu or similar to allow the user to decide what to search for, a album name, band name or year (take a look at http://www.ultimate-guitar.com tab search) and then use a sql query based on that.

any help would be appreciated.

tnx
kumar
Hey i have the same question. My code:

Code: Select all

switch ($dop)
    {
      case "submit":
      if ($topic!="-------")
      {
        $engine=mysql_query("select * from $topic where $category like '$what%'") or die(mysql_error());
        while ( $swhat=mysql_fetch_array($engine))
          {
            $sresult=$swhatї"$category"];
            ECHO "<table width="100%" cellspacing="0" cellpadding="0">
             <tr>
              <td>$sresult</td>
             </tr>
            </table>";
          &#125;
        
      &#125;
    &#125;
$topic is the var sent from a drop menu with the topics of my site.
$category is the category of the topic.
$what is the search term.

But when i try to search eg: "hello" in topic "news" category "story"
i get a "There is no column named story". But i know there is one :roll:

[Split due to topic hijack -- JAM]

Posted: Sun Nov 30, 2003 3:08 pm
by Linkjames
You haven't selected a database. Do you need to on your configuration?

Posted: Sun Nov 30, 2003 3:10 pm
by basdog22
No the database is always selected in an included file