PHP Searching Problem...

Thread Solved

Join Date: Aug 2007
Posts: 121
Reputation: hemgoyal_1990 is an unknown quantity at this point 
Solved Threads: 8
hemgoyal_1990's Avatar
hemgoyal_1990 hemgoyal_1990 is offline Offline
Junior Poster

PHP Searching Problem...

 
0
  #1
Mar 30th, 2008
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
  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
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 25
Reputation: BroKeN is an unknown quantity at this point 
Solved Threads: 1
BroKeN's Avatar
BroKeN BroKeN is offline Offline
Light Poster

Re: PHP Searching Problem...

 
0
  #2
Mar 30th, 2008
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
<FORM Action="/Search.php" Method="POST">
To make something from nothing i a challenge
The top of The Plesure is to WIN the challenge

IraqHiTs Forums Bringing Back The Noise
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 121
Reputation: hemgoyal_1990 is an unknown quantity at this point 
Solved Threads: 8
hemgoyal_1990's Avatar
hemgoyal_1990 hemgoyal_1990 is offline Offline
Junior Poster

Re: PHP Searching Problem...

 
0
  #3
Mar 30th, 2008
Dear i am Doing Your Tricx But my Problem doe's not solved yet.... Plz Dear Give me Solution of my problem.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: PHP Searching Problem...

 
0
  #4
Mar 30th, 2008
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
$row = @mysql_fetch_array($query)
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 25
Reputation: BroKeN is an unknown quantity at this point 
Solved Threads: 1
BroKeN's Avatar
BroKeN BroKeN is offline Offline
Light Poster

Re: PHP Searching Problem...

 
0
  #5
Mar 30th, 2008
Originally Posted by hemgoyal_1990 View Post
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
To make something from nothing i a challenge
The top of The Plesure is to WIN the challenge

IraqHiTs Forums Bringing Back The Noise
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 121
Reputation: hemgoyal_1990 is an unknown quantity at this point 
Solved Threads: 8
hemgoyal_1990's Avatar
hemgoyal_1990 hemgoyal_1990 is offline Offline
Junior Poster

Re: PHP Searching Problem...

 
0
  #6
Mar 31st, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: PHP Searching Problem...

 
0
  #7
Mar 31st, 2008
Then your query is wrong. What exactly are you trying to do with that query ?
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 121
Reputation: hemgoyal_1990 is an unknown quantity at this point 
Solved Threads: 8
hemgoyal_1990's Avatar
hemgoyal_1990 hemgoyal_1990 is offline Offline
Junior Poster

Re: PHP Searching Problem...

 
0
  #8
Mar 31st, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: PHP Searching Problem...

 
0
  #9
Mar 31st, 2008
Your query should be SELECT * FROM details WHERE columnname LIKE '$_POST[search]'% LIMIT 0, 50
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 160
Reputation: w_3rabi is an unknown quantity at this point 
Solved Threads: 9
w_3rabi's Avatar
w_3rabi w_3rabi is offline Offline
Junior Poster

Re: PHP Searching Problem...

 
0
  #10
Mar 31st, 2008
try printing the sql statement before executing it
that could help u
programming is an art ,only for those who can understand it.
- th3 php wr3nch -
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC