Boggie Posted May 2, 2005 Share Posted May 2, 2005 Hi, i have 3 pages set up on my webpage. 1. Insert record page 2. Search database page 3. Results page All my entry page fields work just fine. The problem is when i go to my search page and enter data, it just goes to the results page. It's suppose to get the data from the search field and filter the results in the database, and display it on the results.php. Search page: [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]require_once([/span][span style=\"color:#DD0000\"]\'Connections/rproject.php\'[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?> <?php $colname_Recordset1 [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"1\"[/span][span style=\"color:#007700\"]; if (isset([/span][span style=\"color:#0000BB\"]$HTTP_POST_VARS[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'textfield\'[/span][span style=\"color:#007700\"]])) { [/span][span style=\"color:#0000BB\"]$colname_Recordset1 [/span][span style=\"color:#007700\"]= ([/span][span style=\"color:#0000BB\"]get_magic_quotes_gpc[/span][span style=\"color:#007700\"]()) ? [/span][span style=\"color:#0000BB\"]$HTTP_POST_VARS[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'textfield\'[/span][span style=\"color:#007700\"]] : [/span][span style=\"color:#0000BB\"]addslashes[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$HTTP_POST_VARS[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'textfield\'[/span][span style=\"color:#007700\"]]); } [/span][span style=\"color:#0000BB\"]mysql_select_db[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$database_rproject[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$rproject[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]$query_Recordset1 [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]sprintf[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"SELECT * FROM rp_users WHERE rp_eventlocation = \'%s\'\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$colname_Recordset1[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]$Recordset1 [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$query_Recordset1[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$rproject[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]()); [/span][span style=\"color:#0000BB\"]$row_Recordset1 [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_assoc[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$Recordset1[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]$totalRows_Recordset1 [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_num_rows[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$Recordset1[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]$currentPage [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$HTTP_SERVER_VARS[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\"PHP_SELF\"[/span][span style=\"color:#007700\"]]; [/span][span style=\"color:#0000BB\"]$queryString_raidsearch [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]; if (&[/span][span style=\"color:#FF8000\"]#33;empty($HTTP_SERVER_VARS[\'QUERY_STRING\'])) { [/span][span style=\"color:#0000BB\"]$params [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]explode[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"&\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$HTTP_SERVER_VARS[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'QUERY_STRING\'[/span][span style=\"color:#007700\"]]); [/span][span style=\"color:#0000BB\"]$newParams [/span][span style=\"color:#007700\"]= array(); foreach ([/span][span style=\"color:#0000BB\"]$params [/span][span style=\"color:#007700\"]as [/span][span style=\"color:#0000BB\"]$param[/span][span style=\"color:#007700\"]) { if ([/span][span style=\"color:#0000BB\"]stristr[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$param[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"pageNum_raidsearch\"[/span][span style=\"color:#007700\"]) == [/span][span style=\"color:#0000BB\"]false [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]stristr[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$param[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"totalRows_raidsearch\"[/span][span style=\"color:#007700\"]) == [/span][span style=\"color:#0000BB\"]false[/span][span style=\"color:#007700\"]) { [/span][span style=\"color:#0000BB\"]array_push[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$newParams[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$param[/span][span style=\"color:#007700\"]); } } if ([/span][span style=\"color:#0000BB\"]count[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$newParams[/span][span style=\"color:#007700\"]) &[/span][span style=\"color:#FF8000\"]#33;= 0) { [/span][span style=\"color:#0000BB\"]$queryString_raidsearch [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"&\" [/span][span style=\"color:#007700\"]. [/span][span style=\"color:#0000BB\"]implode[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"&\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$newParams[/span][span style=\"color:#007700\"]); } } [/span][span style=\"color:#0000BB\"]$queryString_raidsearch [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]sprintf[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"&totalRows_raidsearch=%d%s\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$totalRows_raidsearch[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$queryString_raidsearch[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?> [/span] <html> <head> <title>Raid Project Search by Whoaguild.com</title> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> </head> <body> <p><strong><font size=\"6\"><em>Raid Project Event Search Form</em></font></strong><em><font style=\"color:#FF0000\">beta </font></em></p> <p> </p> <form action=\"raidresults.php\" method=\"post\" name=\"raidsearch\" id=\"raidsearch\"> <table width=\"100%\" border=\"0\"> <tr> <td width=\"16%\">Event Location: </td> <td width=\"84%\"> <input name=\"textfield\" type=\"text\" value=\"[span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]echo [/span][span style=\"color:#0000BB\"]$row_Recordset1[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'rp_eventlocation\'[/span][span style=\"color:#007700\"]]; [/span][span style=\"color:#0000BB\"]?>[/span]\"></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> <input type=\"submit\" name=\"Submit\" value=\"Search\"></td> <td> <input type=\"reset\" name=\"Submit2\" value=\"Reset\"></td> </tr> <tr> <td> </td> <td> </td> </tr> </table> </form> <p> </p> <p> </p> </body> </html> [span style=\"color:#0000BB\"]<?php mysql_free_result[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$Recordset1[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?> [/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] Results page: [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]require_once([/span][span style=\"color:#DD0000\"]\'Connections/rproject.php\'[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?> [/span] [span style=\"color:#0000BB\"]<?php mysql_select_db[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$database_rproject[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$rproject[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]$query_Recordset1 [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"SELECT * FROM rp_users\"[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#0000BB\"]$Recordset1 [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$query_Recordset1[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$rproject[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]()); [/span][span style=\"color:#0000BB\"]$row_Recordset1 [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_assoc[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$Recordset1[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]$totalRows_Recordset1 [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_num_rows[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$Recordset1[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]$currentPage [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$HTTP_SERVER_VARS[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\"PHP_SELF\"[/span][span style=\"color:#007700\"]]; [/span][span style=\"color:#0000BB\"]$queryString_eventlocationresults [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]; if (&[/span][span style=\"color:#FF8000\"]#33;empty($HTTP_SERVER_VARS[\'QUERY_STRING\'])) { [/span][span style=\"color:#0000BB\"]$params [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]explode[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"&\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$HTTP_SERVER_VARS[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'QUERY_STRING\'[/span][span style=\"color:#007700\"]]); [/span][span style=\"color:#0000BB\"]$newParams [/span][span style=\"color:#007700\"]= array(); foreach ([/span][span style=\"color:#0000BB\"]$params [/span][span style=\"color:#007700\"]as [/span][span style=\"color:#0000BB\"]$param[/span][span style=\"color:#007700\"]) { if ([/span][span style=\"color:#0000BB\"]stristr[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$param[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"pageNum_eventlocationresults\"[/span][span style=\"color:#007700\"]) == [/span][span style=\"color:#0000BB\"]false [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]stristr[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$param[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"totalRows_eventlocationresults\"[/span][span style=\"color:#007700\"]) == [/span][span style=\"color:#0000BB\"]false[/span][span style=\"color:#007700\"]) { [/span][span style=\"color:#0000BB\"]array_push[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$newParams[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$param[/span][span style=\"color:#007700\"]); } } if ([/span][span style=\"color:#0000BB\"]count[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$newParams[/span][span style=\"color:#007700\"]) &[/span][span style=\"color:#FF8000\"]#33;= 0) { [/span][span style=\"color:#0000BB\"]$queryString_eventlocationresults [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"&\" [/span][span style=\"color:#007700\"]. [/span][span style=\"color:#0000BB\"]implode[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"&\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$newParams[/span][span style=\"color:#007700\"]); } } [/span][span style=\"color:#0000BB\"]$queryString_eventlocationresults [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]sprintf[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"&totalRows_eventlocationresults=%d%s\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$totalRows_eventlocationresults[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$queryString_eventlocationresults[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?> [/span] <html> <head> <title>Untitled Document</title> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> </head> <body> <p><strong><font size=\"6\"><em>Raid Project Event Results Page</em></font></strong><em><font style=\"color:#FF0000\">beta</font></em> </p> <center> <table width=\"100%\" border=\"0\"> <tr> <td>Name</td> <td>Server</td> </tr> [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]do { [/span][span style=\"color:#0000BB\"]?> [/span] <tr> <td>[span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]echo [/span][span style=\"color:#0000BB\"]$row_Recordset1[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'rp_name\'[/span][span style=\"color:#007700\"]]; [/span][span style=\"color:#0000BB\"]?>[/span]</td> <td>[span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]echo [/span][span style=\"color:#0000BB\"]$row_Recordset1[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'rp_server\'[/span][span style=\"color:#007700\"]]; [/span][span style=\"color:#0000BB\"]?>[/span]</td> </tr> [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]} while ([/span][span style=\"color:#0000BB\"]$row_Recordset2 [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_assoc[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$Recordset2[/span][span style=\"color:#007700\"])); [/span][span style=\"color:#0000BB\"]?> [/span] </table> </center> <p> </p> </body> </html> [span style=\"color:#0000BB\"]<?php mysql_free_result[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$Recordset1[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?> [/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] Currently the search page is limited to searching for only the Event Location Later i will add a search for: Guild name, Event time I am using Dreamweaver MX to do all the coding. When i enter search criteria, the results page displays every entry in my database, rather than the criteria i enter in the search box on the search page Thanks in advanced Quote Link to comment https://forums.phpfreaks.com/topic/2288-query-search-from-a-search-field/ 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.