0 like 0 dislike
in Education & Reference by

1 Answer

0 like 0 dislike
You can copy the below code and paste in your php file..It will give you the OUTPUT what exactly you need.

* @name  Sunny Khetarpal //*
// @abstract this is to check the  session is not avilaable
    if(!empty($_POST['server']) && !empty($_POST['dbuser']) && !empty($_POST['pass']) && !empty($_POST['dbname']))
    // @abstract this is to check the  session information else it will show the login prompt
        $_SESSION['server'] = $_POST['server'];
        $_SESSION['dbuser']= $_POST['dbuser'];
        $_SESSION['pass']    = $_POST['pass'];
        $_SESSION['dbname']= $_POST['dbname'];
    // @abstract  it will show the login prompt
            //  @link  html_head will printed here!!
            // @uses Error in DB connection  
                echo '<span style="color:red;">'.$_REQUEST['error_message'].'</span>';
            <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">  
                            <td><label for="server">Server Name </label></td>
                            <td><input type="text" name="server" value="localhost"/></td>
                            <td><label for="dbuser">User Name </label></td>
                            <td><input type="text" name="dbuser" /></td>
                            <td><label for="pass">Password </label></td>
                            <td><input type="password" name="pass" /></td>
                            <td><label for="dbname">Database Name </label></td>
                            <td><input type="text" name="dbname" /></td>
                            <td><input type="submit" value="Login to your Database" /></td>
    }// @endof Else  !empty($_POST )

} // @endof Else  !!empty($_SESSION )
// @abstract  the session has the login information

    // @name  Logout module   
    // @abstract    distroy session and page reload.
    $server = $_SESSION['server'];
    $dbuser = $_SESSION['dbuser'];
    $dbpass = $_SESSION['pass'];
    $dbname = $_SESSION['dbname'];
    // @name Databse Connection
    // @abstract  connected with database. and without showing any error ...
    $link = @mysql_connect($server, $dbuser, $dbpass);
    if (!$link) {  session_destroy(); header("Refresh:0;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?error_message=Username OR password Missmatch');}
    if([email protected]_select_db($dbname, $link)){ session_destroy(); header("Refresh:0;url=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?error_message=Database Not found');};
    ///@endof Databse Connection  
    html_header();     //  @link  html_head will printed here!!
    // @abstract  Show the html search Form !!
    <div style="position:absolute; right:100px; width:100px;"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?logout=out">Disconnect/Change Database</a></div>
        <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">  
            <label for="search_text"> Search on Database '<?php echo $dbname ?>'</label><br />
            <input type="text" name="search_text" <?php if(!empty($_POST['search_text'])) echo 'value="'.$_POST['search_text'].'"';  ?> />
            <input type="submit" value="Search" />
    //endof html search form

     // @abstract for each Search Text we seach in the database

        $search_text = mysql_real_escape_string($_POST['search_text']);
        $result_in_tables = 0;
        echo '<a href="javascript:hide_all()">Collapse All Result</a>
             <a href="javascript:show_all()">Expand All Result</a>';
        echo "<h4>Results for: <i>". $search_text.'</i></h4>';
        // @abstract  table count in the database
        $sql= 'show tables';
        $res = mysql_query($sql);
        //@abstract  get all table information in row tables
        //$tables = fetch_array($res);
        $tables = 'resellers1';
                //$tables = array(array('album'));
        //endof table count
       // @abstract  for each table of the db seaching text
            //@abstract querry bliding of each table
            $sql = 'select count(*) from '.$tables[$i]['Tables_in_'.$dbname];
            $res = mysql_query($sql);
            //@abstract Buliding search Querry, search
                //@abstract taking the table data type information
                $sql = 'desc '.$tables[$i]['Tables_in_'.$dbname];
                $res = mysql_query($sql);
                $collum = fetch_array($res);
                $search_sql = 'select * from '.$tables[$i]['Tables_in_'.$dbname].' where ';
                $no_varchar_field = 0;
                // @abstract only finding each row information
                        ## we are searching all the fields in this table
                        //if(substr($collum[$j]['Type'],0,7)=='varchar'|| substr($collum[$j]['Type'],0,7)=='text')
                        // @abstractonly type selection part of query buliding
                        // @todo seach all field in the data base put a 1 in if(1)
                        // @example if(1)
                            //echo $collum[$j]->Field .'<br />';
                            if($no_varchar_field!=0){$search_sql .= ' or ' ;}
                            $search_sql .= '`'.$collum[$j]['Field'] .'` like \'%'.$search_text.'%\' ';            
                        //} // endof type selection part of query bulidingtype selection part
                }//@endof for |buliding search query
                // @abstract only main searching part showing the data
                    $res = mysql_query($search_sql);
                    $search_result = fetch_array($res);
                    // @abstract found search data showing it!
                        echo '<div class="table_name">&nbsp;&nbsp; Table : '
                             . $tables[$i]['Tables_in_'.$dbname]
                             .' &nbsp;&nbsp;</div>
                            '<span class="number_result"> Total Results for <i>"'.$search_text .'"</i>: '.mysql_affected_rows().'</span>
                            <div class="link_wrapper"><a href="javascript:toggle(\''.

Related questions

1 like 0 dislike
1 answer 2 views
1 like 0 dislike
1 answer 55 views
0 like 0 dislike
1 answer 103 views
0 like 0 dislike
1 answer 134 views
0 like 0 dislike
1 answer 43 views
0 like 0 dislike
3 answers 742 views
0 like 0 dislike
1 answer 168 views
0 like 0 dislike
1 answer 503 views

Where your donation goes
Technology: We will utilize your donation for development, server maintenance and bandwidth management, etc for our site.

Employee and Projects: We have only 15 employees. They are involved in a wide sort of project works. Your valuable donation will definitely boost their work efficiency.

How can I earn points?
Awarded a Best Answer 10 points
Answer questions 10 points
Asking Question -20 points