0

hi
i want to know that how can i search the entire database at once....
i have code with which i can only search from a single table but i want that search should be performed on
entire database....
i m using php+mysql.......
help me out...

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by mcastu
0

i just need to use stars only?no need to give the table name....it'll automatically fetch records from all tables??????

0

yes.it will check all the columns of all the tables of any database

SELECT * FROM * WHERE * LIKE '%your_search_string%'

first * is for all the fields
second for all the tables
third for all the columns of the tables on which you want to apply search criteria. In other words, it will give you results from all the database. Try it.

Cheers

0

i hve used your query......but m still getting one error.m sending you the code ........
-----------search.php------------------

<HTML>
<HEAD>
 <TITLE>New Document</TITLE>
</HEAD>
<BODY>
  <form type="GET" action="result.php">
<input type="text" name="key">
<input type="submit" value="Search">
</form>
</BODY>
</HTML>

------------------------result.php------------------------------

<?php
 $db_server = "localhost";
     $db_name = "master";
     $db_username = "root";
     $db_password = "root";
     function db_connect(){

    global $db_server;
    global $db_name;
    global $db_username;
    global $db_password;

    $con =@ mysql_connect($db_server,$db_username,$db_password);
    if ($con!=false){
        if (!(mysql_select_db($db_name,$con))){
            // cannot find database
            die("Cannot find Database");
        } else {
            // fine
        }
    } else {
        die ("Cannot connect to database");
    }
return $con;
}
function db_search($key) {
        $con = db_connect();
    $key = mysql_escape_string($key);
    $sql = "SELECT * FROM * WHERE * LIKE '%".$key."%'";
        $result = mysql_query($sql,$con);
        mysql_close($con);
    return $result;
}
if(isset($_REQUEST['key']))
{
   $key = $_REQUEST['key'];
   $result = db_search_bible($key);
  if($result == FALSE)
    $content = 'No Match Found';

else
    while ($row = mysql_fetch_row($result)) {
            $content .=  $row[0].', '.$row[1].', '.$row[2].’,  '.$row[3].'…<br>';
}

echo $content;
?>

error i am facing is.......................
Parse error: parse error in c:\apache\htdocs\newhr\result.php on line 43

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.