Wednesday 15 February 2012

html - Search method using PHP MYSQL -



html - Search method using PHP MYSQL -

i'm trying utilize search retrieve option, simpliest form of searching, can these codes, no error not working. please indicate wrong in 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 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 * tblnews udate '%$searchq%'"); $count = mysql_num_rows($query); if($count==0) { $output = 'there 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 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>

change

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

to

<input type="submit" name="searchbutton" value="search">

php html mysql

No comments:

Post a Comment