|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
PHP / SQL database Query problem...
Hi,
I have a problem with some code not working properly. The page uses a search box to serach for entries in a datbase table using a php ID call. I just cant see why this does'nt work ...! Here's the code.. <?php require("header2.php3"); ?> <table cellspacing=1 cellpadding=2 border=0 width=600 valign=top background=bgplain.gif> <tr><td colspan=2 bgcolor=#aedaff align=center valign=middle><font size=2 color=#003366><B> Search Results</B> </td></tr> <?php require("db.php3"); ?> <? $result = mysql_query("select * FROM abstracts where titleab like '%$searchname%' or authors like '%$searchname%' or journal like '%$searchname%' or abstract like '%$searchname%'"); $numrows = mysql_num_rows($result); if($numrows == 0) { echo("<table width=600 background=bgplain.gif><tr><td align=center><br><b>There are no Abstracts in the database matching your search criteria please refine your search. <a href=abstracts.html><font color=orange>Go Back</a></b></td></tr></table>"); } while($row = mysql_fetch_array($result)) { echo(" <tr> <td align=right valign=top width=25%> <font face=arial size=1 color=orange> <B>Title: </B> </td> <td align=left valign=top> <font face=arial size=1 color=ffffff> <B>$row[titleab]</B> </td></tr> <tr> <td align=right valign=top width=25%> <font face=arial size=1 color=orange> <B>Authors: </B> </td> <td align=left valign=top> <font face=arial size=1 color=ffffff> $row[authors] </td></tr> <tr> <td align=right valign=top width=25%> <font face=arial size=1 color=orange> <B>Journal/Conference: </B> </td> <td align=left valign=top> <font face=arial size=1 color=ffffff> $row[journal] </td></tr> <tr> <td align=right valign=top width=25%> <font face=arial size=1 color=orange> <B>Date: </B> </td> <td align=left valign=top> <font face=arial size=1 color=ffffff> $row[date] </td></tr> <tr> <td align=right valign=top> </td> <td align=left valign=bottom> <a href="abstractsmore.php3?id=$row[id]"><font face=arial size=1 color=orange><img src=images/bullet.gif border=0 > Complete Abstract </a> </font></td></tr> <tr><td colspan=2 align=right> <a href=abstracts.html><font color=#aedaff><img src=images/bulletback.gif border=0> <B>Go Back</a></b><P></td></tr> "); } ?> </table> <?php require("footer2.php3"); ?> Thanks in advance. Ronan. |
|
#2
|
|||
|
|||
|
RE: PHP / SQL database Query problem...
What is the specific problem you are having? No Output?, Error message? Let us know so we have more information to help troubleshoot.
|
|
#3
|
|||
|
|||
|
RE: PHP / SQL database Query problem...
Hi,
Basically after you input your search identifier, say the name of an author or abstarct title, the result just returns the full list again. so basically no search takes place.... Thanks in advance... |
|
#4
|
|||
|
|||
|
RE: PHP / SQL database Query problem...
did you make sure that your search string wasn't blank before you ran the query?
|
|
#5
|
|||
|
|||
|
RE: PHP / SQL database Query problem...
jaltiere makes a good point... are the search criteria every making it to the query? If not, then yes the full list would be output
try echoing the $searchname variable prior to running the query to see if there is a value. I think that register globals is set to off in your php.ini file so you should try this. [highlight=php] <? $searchname = $_POST['searchname'] ?> place this code just before the query and it should work. I would also include a check to see if the searchname variable has a value assigned to it before running the query. Note, if you are using the GET method in your form, change $_POST above to $_GET |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > PHP / SQL database Query problem... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|