943,791 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 995
  • PHP RSS
Mar 30th, 2008
0

PHP Searching Problem...

Expand Post »
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 :-
Search.php
php Syntax (Toggle Plain Text)
  1. <HTML>
  2. <BODY>
  3. <FORM Action="/Search.php" Method="POST">
  4. <div align="center">
  5. <table border="0" cellpadding="0" cellspacing="0">
  6. <tr>
  7. <td bordercolor="#000000">
  8. <p align="center">
  9. <select name="metode" size="1">
  10. <option value="name">Name</option>
  11. <option value="telephone">Telephone</option>
  12. <option value="birthday">Birthday</option>
  13. </select> <input type="text" name="search" size="25"> &nbsp;<br>
  14. Search database: <input type="submit" value="Go!!" name="Go"></p>
  15. </td>
  16. </tr>
  17. </table>
  18. </div>
  19. </form>
  20.  
  21.  
  22. <center>
  23. <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
  24. <tr>
  25. <td width="60"><b>ID</b></td>
  26. <td width="100"><b>Name</b></td>
  27. <td width="70"><b>Telephone</b></td>
  28. <td width="150"><b>Birthday</b></td>
  29. </tr>
  30.  
  31. <?php
  32. if ($_POST['Go'])//user clicks go..
  33. {
  34. $dbh=mysql_connect ("localhost", "kuchcity_hemant", "hemgoyal") or die ('I cannot connect to the database because: ' . mysql_error());
  35. mysql_select_db ("kuchcity_example");
  36. ?>
  37. <?php
  38.  
  39. //error message (not found message)begins
  40. $XX = "No Record Found, to search again please try again";
  41. //query details table begins
  42.  
  43. $query = mysql_query("SELECT * FROM details WHERE '$_POST[metode]' LIKE '$_POST[search]'% LIMIT 0, 50");
  44. while ($row = @mysql_fetch_array($query))
  45. {
  46. $variable1=$row["ID"];
  47. $variable2=$row["Name"];
  48. $variable3=$row["Telephone"];
  49. $variable4=$row["Birthday"];
  50. //table layout for results
  51.  
  52. print ("<tr>");
  53. print ("<td>$variable1</td>");
  54. print ("<td>$variable2</td>");
  55. print ("<td>$variable3</td>");
  56. print ("<td>$variable4</td>");
  57. print ("</tr>");
  58. }
  59. //below this is the function for no record!!
  60. if (!$variable1)
  61. {
  62. print ("$XX");
  63. }
  64. //end
  65. }
  66. ?>
  67. </table>
  68. </center>
  69. </BODY>
  70. </HTML>

any one plz help me......
Last edited by peter_budo; Mar 30th, 2008 at 6:21 am. Reason: Keep It Organized - please use [code] tags
Reputation Points: 18
Solved Threads: 17
Junior Poster
hemgoyal_1990 is offline Offline
175 posts
since Aug 2007
Mar 30th, 2008
0

Re: PHP Searching Problem...

Hi
hemgoyal

you have this one in line 3 which i marked it in red move it to small litter and chick and let me know
Quote ...
<FORM Action="/Search.php" Method="POST">
Reputation Points: 10
Solved Threads: 1
Light Poster
BroKeN is offline Offline
25 posts
since Mar 2008
Mar 30th, 2008
0

Re: PHP Searching Problem...

Dear i am Doing Your Tricx But my Problem doe's not solved yet.... Plz Dear Give me Solution of my problem.
Reputation Points: 18
Solved Threads: 17
Junior Poster
hemgoyal_1990 is offline Offline
175 posts
since Aug 2007
Mar 30th, 2008
0

Re: PHP Searching Problem...

Quote ...
SELECT * FROM details WHERE '$_POST[metode]' LIKE '$_POST[search]'% LIMIT 0, 50
I guess $_POST['metode'] is the column name ? Print out the query, execute it in phpmyadmin/ mysql console. Check the result. Oh, also, remove the @ symbol from
Quote ...
$row = @mysql_fetch_array($query)
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Mar 30th, 2008
0

Re: PHP Searching Problem...

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
if you can post it i think i can help and do try what nav33n said
still around you
brb
Reputation Points: 10
Solved Threads: 1
Light Poster
BroKeN is offline Offline
25 posts
since Mar 2008
Mar 31st, 2008
0

Re: PHP Searching Problem...

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.
Reputation Points: 18
Solved Threads: 17
Junior Poster
hemgoyal_1990 is offline Offline
175 posts
since Aug 2007
Mar 31st, 2008
0

Re: PHP Searching Problem...

Then your query is wrong. What exactly are you trying to do with that query ?
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Mar 31st, 2008
0

Re: PHP Searching Problem...

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.
Reputation Points: 18
Solved Threads: 17
Junior Poster
hemgoyal_1990 is offline Offline
175 posts
since Aug 2007
Mar 31st, 2008
0

Re: PHP Searching Problem...

Your query should be SELECT * FROM details WHERE columnname LIKE '$_POST[search]'% LIMIT 0, 50
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Mar 31st, 2008
0

Re: PHP Searching Problem...

try printing the sql statement before executing it
that could help u
Reputation Points: 18
Solved Threads: 9
Junior Poster
w_3rabi is offline Offline
160 posts
since Dec 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: help in mail attachment
Next Thread in PHP Forum Timeline: php mail





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC