rogerc Posted April 17, 2008 Share Posted April 17, 2008 hi i am having problems with displaying results from my databse. The first part of the code search.html runs when selcted from my main menu.The problem is when I hit the submit button the results.php page does'nt appear, anybody have any idea why this is happening thanks roger c heres the code search.html <html> <head> <title></title> </head> <body> <h1> </h1> <form action="results.php" method="post"> Enter In Student Name:<br/> <input name="searchterm" type="text"> <br/> <input type="submit"value="Search"> </form> </body> </html> results.php ... <html> <head> <title></title> </head> <body> <h1>Student Search Result</h1> <? // create short variable names $searchterm = $$HTTP_POST_VARS['searchterm']; $searchterm = trim($searchterm); if (!$searchterm ) { echo 'You have not entered search details. Please go back and try again.'; exit; } if (!get_magic_quotes_gpc()) { $searchterm = addslashes($searchterm); } $db_name = "resultsdb"; @ $db = mysql_connect('localhost', 'resultsdb'); if( !$db) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = "select * from grades where like '%".$searchterm."%'"; $result = $db->query($query); $num_results = $result->num_rows; echo '<p>Number of Students found: '.$num_results.'</p>'; for ($i=0; $i < $num_results; $i++) { $row = $result->fetch_assoc(); echo '<p><strong>'.($i+1). '. Title: '; echo htmlspecialchars(stripslashes($row['f_name'])); echo '</strong><br />Author: '; echo stripslashes($row['l_name']); echo '<br />ISBN: '; echo stripslashes($row['address1']); echo '<br />Price: '; echo stripslashes($row['address2']); echo '<br />Price: '; echo stripslashes($row['address3']); echo '<br />Price: '; echo stripslashes($row['english']); echo '<br />Price: '; echo stripslashes($row['irish']); echo '<br />Price: '; echo stripslashes($row['math']); echo '<br />Price: '; echo stripslashes($row['science']); echo '<br />Price: '; echo stripslashes($row['geography']); echo '<br />Price: '; echo stripslashes($row['history']); echo '</p>'; } $result->free(); $db->close(); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
mofm Posted April 17, 2008 Share Posted April 17, 2008 $searchterm = $$HTTP_POST_VARS['searchterm']; needs to be $searchterm = $HTTP_POST_VARS['searchterm']; And $query = "select * from grades where like '%".$searchterm."%'"; $result = $db->query($query); needs to be somthing like $query = "select * from grades where coloumnamehere like '%".$searchterm."%'"; $result = $db->query($query); Quote Link to comment Share on other sites More sharing options...
rogerc Posted April 17, 2008 Author Share Posted April 17, 2008 Hi thanks for getting back to me. I made the changes you said to do but the page is still coming up blank rogerc Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.