|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
need help with searching.... please
Hi i need to be able to search through my database and the code that I have is not working, please help.... the code is below..., please, i need this to work...
>> this is the search form.. "searchform.html" << <html> <body> <form action=viewdb.php method=GET> Search For: <p> Search: <input type=text name=name size=25 maxlength=25> <p> <input type=submit> </form> </body> </html> >> this is the results page "viewdb.php" << <HTML> <?php $db = mysql_connect("sooty3d", "root", "shadow"); mysql_select_db("companies",$db); $result = mysql_query("SELECT * FROM details where name like '%$name%' order by id",$db); echo "<TABLE>"; echo"<TR><TD><B>id</B><TD><B>Name</B><TD><B>address</B><TD><B>telephone</B></TR>"; while ($myrow = mysql_fetch_array($result)) { echo "<TR><TD>"; echo $myrow["id"]; echo "<TD>"; echo $myrow["name"]; echo "<TD>"; echo $myrow["address"]; echo "<TD>"; echo $myrow["phone"]; } echo "</TABLE>"; ?> </HTML> |
|
#2
|
|||
|
|||
|
RE: need help with searching.... please
well one main problem i see straight away is that your file is named .html, all files with php code must have a .php extension...
|
|
#3
|
|||
|
|||
|
RE: need help with searching.... please
hi, thanks fro replying but the ".html" file contacins no php info at all, it is just the search box...
|
|
#4
|
|||
|
|||
|
RE: need help with searching.... please
hmm...i ran it on my server (changed it to suite my DB) didnt change any code and it worked...what exactly is the problem? are you getting an error or is it just not searching?
|
|
#5
|
|||
|
|||
|
RE: need help with searching.... please
well, it does work but it doesn't search properly. no matter what I input as a search it always just shows every entry in my database... it is soo annoying me... do you know what it could be??? thanks for the help by the way..
|
|
#6
|
|||||
|
|||||
|
RE: need help with searching.... please
I have a search thing on one of my own sites
php Code:
this is my code and it works fine..maybe you can find a problem with your by lookin at this |
|
#7
|
|||
|
|||
|
RE: need help with searching.... please
hi, thanks for all the help[. I haven't been able to use that. All i want to be able to do is a search for a name in the database ad it pattern matches certain names and then lists them. eg. if you typed in "mic", it would result all the names with "m", "i", "c" in them... i just can't do it...
|
|
#8
|
|||
|
|||
|
RE: need help with searching.... please
Is your register globals set on? try using $HTTP_GET_VARS["name"] instead of name?
|
|
#9
|
|||
|
|||
|
RE: need help with searching.... please
sorry, I am just learning this, could you please explain..
|
|
#10
|
|||||
|
|||||
|
RE: need help with searching.... please
check your c:windowsphp.ini (or wherever ur php.ini file is) for register_globals and check that the value next to it is "on"
or change your code to this (some don't like register_globals coz it makes it easier to make mistakes): php Code:
If you have php 4.1+ then you should be able to use $_GET["name"] instead of $HTTP_GET_VARS["name"] though. |
|
#11
|
|||
|
|||
|
RE: need help with searching.... please
thank you so much for all the help, it is nopw sorted.. you ahve been very helpful, I appreciate it so much.. thank you....
|
|
#12
|
|||
|
|||
|
RE: need help with searching.... please
D1NGO's remark actually tipped me off ;) btw : prolly one of the first rules of debugging : print() or echo() the variable you're trying to use first to check that it's really there as u expect it to be.. it's saved me so much time...
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > need help with searching.... please |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|