0

I'm trying to use search as my retrieve option, this is my simpliest form of searching, what can I do with these codes, No error but not working. Please indicate what is wrong in my code. Give advice, site, solution Thanks.

    <?php
    error_reporting(E_ALL); 
    ini_set('display_errors', 1);
    session_start();
    ob_start();

//connetion database
    $dbhost = '192.168.0.9';
    $dbuser = 'dsc';
    $dbpass = 'csd';

    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('ERROR CONNECTING TO MYSQL');

    $dbname = 'dbtips';
    mysql_select_db($dbname);

    $output='';

    if(isset($_POST['search']))
    {
        $searchq = $_POST['search'];
        $searchq = preg_replace("#[^0-9a-z]#i","",$searchq);

//query
        $query = mysql_query("SELECT * FROM tblnews WHERE udate LIKE '%$searchq%'");
        $count = mysql_num_rows($query);

        if($count==0)
        {
            $output = 'There was no search result!';
        }
        else
        {
            while($row = mysql_fetch_array($query)){
                   $udate = $row['udate'];
                   $mis = $row['mis'];
                   $status = $row['status'];



                   $output .= '->'.$udate.'-'.$mis.'-'.$status.'<br>'; 
    }
    }
    }
    ?>      

    //form for searching
    <form action="search.php" method="POST">
    <center>
    <p>
    <input type="text" size="90" name="search" style="text-align:center">
    <br>
    <br>
    <input type="button" name="searchbutton" value="Search">
    <br>
    <br>
    </p>
    </center>
    </form>
3
  • echo " $output .= '->'.$udate.'-'.$mis.'-'.$status.'<br>'"; @Arif_suhail_123 same result sir, thanks Commented Oct 24, 2014 at 6:04
  • Just remove the session stuff at the top and the html part from the bottom, hardcode the POST param and run the script on command line and see what you get. Commented Oct 24, 2014 at 6:04
  • @Arif_suhail_123 the button sir Commented Oct 24, 2014 at 6:32

1 Answer 1

1

change this to

<input type="button" name="searchbutton" value="Search">

To this

<input type="submit" name="searchbutton" value="Search">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.