Hi All, I Have a PHP Searching Code it have some problem it only connet to database but does not show any result..........

PHP Code is :-

<FORM Action="/Search.php" Method="POST"> 
<div align="center">
<table border="0" cellpadding="0" cellspacing="0">
<td bordercolor="#000000">
<p align="center">
<select name="metode" size="1">
<option value="name">Name</option>
<option value="telephone">Telephone</option>
<option value="birthday">Birthday</option>
</select> <input type="text" name="search" size="25"> &nbsp;<br>
Search database: <input type="submit" value="Go!!" name="Go"></p>

<table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
<td width="60"><b>ID</b></td>
<td width="100"><b>Name</b></td>
<td width="70"><b>Telephone</b></td>
<td width="150"><b>Birthday</b></td>

if ($_POST['Go'])//user clicks go..
$dbh=mysql_connect ("localhost", "kuchcity_hemant", "hemgoyal") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("kuchcity_example");

//error message (not found message)begins 
$XX = "No Record Found, to search again please try again"; 
//query details table begins

$query = mysql_query("SELECT * FROM details WHERE '$_POST[metode]' LIKE '$_POST[search]'% LIMIT 0, 50"); 
while ($row = @mysql_fetch_array($query)) 
//table layout for results 

print ("<tr>");
print ("<td>$variable1</td>"); 
print ("<td>$variable2</td>"); 
print ("<td>$variable3</td>"); 
print ("<td>$variable4</td>"); 
print ("</tr>"); 
//below this is the function for no record!!
if (!$variable1)
print ("$XX");

any one plz help me......

8 Years
Discussion Span
Last Post by w_3rabi


you have this one in line 3 which i marked it in red move it to small litter and chick and let me know

<FORM Action="/Search.php" Method="POST">


Dear i am Doing Your Tricx But my Problem doe's not solved yet.... Plz Dear Give me Solution of my problem.


SELECT * FROM details WHERE '$_POST[metode]' LIKE '$_POST[search]'% LIMIT 0, 50

I guess $_POST is the column name ? Print out the query, execute it in phpmyadmin/ mysql console. Check the result. Oh, also, remove the @ symbol from

$row = @mysql_fetch_array($query)


Dear i am Doing Your Tricx But my Problem doe's not solved yet.... Plz Dear Give me Solution of my problem.

Sorry can't help more cuz i don't have the Database you use i just uploaded the "search.php" file to my site and got the issue of the first file reads "Search.php"
and when i typed a name it turned me to "search.php" but with a db error cuz there i cant call your database :P
if you can post it i think i can help and do try what nav33n said
still around you :cool:


No Dear, in this script line
SELECT * FROM details WHERE '$_POST[metode]' LIKE '$_POST[search]'% LIMIT 0, 50 there metode is not not any coloumn this is a POST METHOD.


Dear i Want to Create a Search page so any one user can search data from this page. if u know right coading plz post here.


Your query should be SELECT * FROM details WHERE columnname LIKE '$_POST[search]'% LIMIT 0, 50

This question has already been answered. 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.