Jump to content

Recommended Posts

i'm trying to make a form with multiple text and list menus that query a MySQL database with PHP......can anyone give me an example with multiple fields of one of a tutorial that may help me accomplish this, preferrably one that i can do it with the help of dreamweaver....and also i need to make it were the search results primary ex. venue name is an hyperlink to a detailed page....so the viewers can get more information about the venue.....or topic searching for....

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/
Share on other sites

I dont have a tutorial for this but here is a page I have that does want your asking for. Have to do this in three posts lol

 

page1.php

 

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]

[span style=\"color:#0000BB\"]<?php

[/span][span style=\"color:#FF8000\"]//Function Sets Session Connect Variable

[/span][span style=\"color:#0000BB\"]session_start[/span][span style=\"color:#007700\"]();

[/span][span style=\"color:#0000BB\"]session_register[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"mysql_mylink\"[/span][span style=\"color:#007700\"]);

require([/span][span style=\"color:#DD0000\"]\"pagelook.inc\"[/span][span style=\"color:#007700\"]);

echo [/span][span style=\"color:#DD0000\"]\"<font size=\'8\' color=\'#000000\'><H1 align=center>Arrester Search Request</H1></font>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]         echo [/span][span style=\"color:#DD0000\"]\"<center><form action=page2.php method=post>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]     [/span][span style=\"color:#007700\"]echo [/span][span style=\"color:#DD0000\"]\"<TABLE BORDER=1 align=center>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]         echo [/span][span style=\"color:#DD0000\"]\"<td>*Type:</td><td><INPUT maxLength=50 name=ArresterType size=30></td></tr>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]         echo [/span][span style=\"color:#DD0000\"]\"<td>Mcov:</td><td><INPUT maxLength=50 name=ArresterMcov size=30></td></tr>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]         echo [/span][span style=\"color:#DD0000\"]\"<td>Rating:</td><td><INPUT maxLength=50 name=ArresterRating size=30></td></tr>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]         echo [/span][span style=\"color:#DD0000\"]\"<td>Creep:</td><td><INPUT maxLength=50 name=ArresterCreep size=30></td></tr>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]         echo [/span][span style=\"color:#DD0000\"]\"<td>Description:</td><td><INPUT maxLength=50 name=ArresterDescription size=30</td></tr>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]         echo [/span][span style=\"color:#DD0000\"]\"<td>*MultiRated :</td><td><select name=ArresterMultiRated>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]         echo [/span][span style=\"color:#DD0000\"]\"<option value=\'TRUE\'>TRUE</option>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]         echo [/span][span style=\"color:#DD0000\"]\"<option value=\'FALSE\'>FALSE</option>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]         echo [/span][span style=\"color:#DD0000\"]\"</select></td></tr></table>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]         echo [/span][span style=\"color:#DD0000\"]\"<p><input type=submit name=cmd value=\'Search Records\'>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]         echo [/span][span style=\"color:#DD0000\"]\"</FORM>* - Required Fields</center>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]?>[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8075
Share on other sites

page2.php Part 1

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?php

session_start[/span][span style=\"color:#007700\"]();

[/span][span style=\"color:#0000BB\"]session_register[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"mysql_mylink\"[/span][span style=\"color:#007700\"]);

require([/span][span style=\"color:#DD0000\"]\"pagelook.inc\"[/span][span style=\"color:#007700\"]);

echo [/span][span style=\"color:#DD0000\"]\"<font size=\'8\' color=\'#000000\'><H1 align=center>Arrester Search Request</H1></font>\"[/span][span style=\"color:#007700\"];

function [/span][span style=\"color:#0000BB\"]SearchRecordReturnMatch[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$ArresterType[/span][span style=\"color:#007700\"],[/span][span style=\"color:#0000BB\"]$ArresterMcov[/span][span style=\"color:#007700\"],[/span][span style=\"color:#0000BB\"]$ArresterRating[/span][span style=\"color:#007700\"],[/span][span style=\"color:#0000BB\"]$ArresterCreep[/span][span style=\"color:#007700\"],[/span][span style=\"color:#0000BB\"]$ArresterDescription[/span][span style=\"color:#007700\"],[/span][span style=\"color:#0000BB\"]$ArresterMultiRated[/span][span style=\"color:#007700\"]){

[/span][span style=\"color:#0000BB\"]$strcnta1 [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]strlen[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$ArresterMultiRated[/span][span style=\"color:#007700\"]);

if ([/span][span style=\"color:#0000BB\"]$strcnta1 [/span][span style=\"color:#007700\"]> [/span][span style=\"color:#0000BB\"]1[/span][span style=\"color:#007700\"]) {

   echo [/span][span style=\"color:#DD0000\"]\"<TABLE BORDER=1 align=center>\"[/span][span style=\"color:#007700\"];

   echo [/span][span style=\"color:#DD0000\"]\"<TD>Type</TD><TD>Mcov</TD><TD>Rated</TD><TD>Creep</TD><TD>Description</TD><TD>Multi Rated</TD><TR>\"[/span][span style=\"color:#007700\"];

   echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$ArresterType[/span][span style=\"color:#007700\"].[/span][span style=\"color:#DD0000\"]\"</td><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$ArresterMcov[/span][span style=\"color:#007700\"].[/span][span style=\"color:#DD0000\"]\"</td><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$ArresterRating[/span][span style=\"color:#007700\"].[/span][span style=\"color:#DD0000\"]\"</td>\"[/span][span style=\"color:#007700\"];

   echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$ArresterCreep[/span][span style=\"color:#007700\"].[/span][span style=\"color:#DD0000\"]\"</td><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$ArresterDescription[/span][span style=\"color:#007700\"].[/span][span style=\"color:#DD0000\"]\"</td><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$ArresterMultiRated[/span][span style=\"color:#007700\"].[/span][span style=\"color:#DD0000\"]\"</td>\"[/span][span style=\"color:#007700\"];

   echo [/span][span style=\"color:#DD0000\"]\"</TR></table><p>\"[/span][span style=\"color:#007700\"];

   [/span][span style=\"color:#0000BB\"]mysql_select_db [/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"all_arr\"[/span][span style=\"color:#007700\"]);

   echo [/span][span style=\"color:#DD0000\"]\"<TABLE class=\'sortable\' id=\'allarr1\' BORDER=1 align=center>\"[/span][span style=\"color:#007700\"];

   echo [/span][span style=\"color:#DD0000\"]\"<TD>Catalog Number</TD><TD>Type</TD><TD>Mcov</TD><TD>Rated</TD><TD>Creep</TD><TD>Description</TD>\"[/span][span style=\"color:#007700\"];

   echo [/span][span style=\"color:#DD0000\"]\"<TD>Customer</TD><TD>Stat</TD><TD>Multi Rated</TD><TD>First Mcov</TD><TD>Second Mcov</TD>\"[/span][span style=\"color:#007700\"];

   echo [/span][span style=\"color:#DD0000\"]\"<TD>Third Mcov</TD><TD>Fourth Mcov</TD><TD>Color</TD>\"[/span][span style=\"color:#007700\"];

   [/span][span style=\"color:#0000BB\"]$MinArrCrp [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$ArresterCreep [/span][span style=\"color:#007700\"]* [/span][span style=\"color:#0000BB\"]0.90[/span][span style=\"color:#007700\"];

   [/span][span style=\"color:#0000BB\"]$MinArrMcov [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$ArresterMcov [/span][span style=\"color:#007700\"]* [/span][span style=\"color:#0000BB\"]0.90[/span][span style=\"color:#007700\"];

   [/span][span style=\"color:#0000BB\"]$MinArrRating [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$ArresterRating [/span][span style=\"color:#007700\"]* [/span][span style=\"color:#0000BB\"]0.90[/span][span style=\"color:#007700\"];

   [/span][span style=\"color:#0000BB\"]$MaxArrCrp [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$ArresterCreep [/span][span style=\"color:#007700\"]* [/span][span style=\"color:#0000BB\"]1.10[/span][span style=\"color:#007700\"];

   [/span][span style=\"color:#0000BB\"]$MaxArrMcov [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$ArresterMcov [/span][span style=\"color:#007700\"]* [/span][span style=\"color:#0000BB\"]1.10[/span][span style=\"color:#007700\"];

   [/span][span style=\"color:#0000BB\"]$MaxArrRating [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$ArresterRating [/span][span style=\"color:#007700\"]* [/span][span style=\"color:#0000BB\"]1.10[/span][span style=\"color:#007700\"];

[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8076
Share on other sites

page2.php Part 2

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]   if ($ArresterCreep != \"\" && $ArresterMcov != \"\" && $ArresterRating != \"\") {$querystring = \"select * from all_arr where (Type like \'$ArresterType%\') and (Mcov between $MinArrMcov and $MaxArrMcov) and (Rating between $MinArrRating and $MaxArrRating) and (Creep between $MinArrCrp and $MaxArrCrp) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\";}

   if ($ArresterCreep != \"\" && $ArresterMcov != \"\" && $ArresterRating == \"\") {$querystring = \"select * from all_arr where (Type like \'$ArresterType%\') and (Mcov between $MinArrMcov and $MaxArrMcov) and (Creep between $MinArrCrp and $MaxArrCrp) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\";}

   if ($ArresterCreep != \"\" && $ArresterMcov == \"\" && $ArresterRating == \"\") {$querystring = \"select * from all_arr where (Type like \'$ArresterType%\') and (Creep between $MinArrCrp and $MaxArrCrp) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\";}

   if ($ArresterCreep != \"\" && $ArresterMcov == \"\" && $ArresterRating != \"\") {$querystring = \"select * from all_arr where (Type like \'$ArresterType%\') and (Rating between $MinArrRating and $MaxArrRating) and (Creep between $MinArrCrp and $MaxArrCrp) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\";}

   if ($ArresterCreep == \"\" && $ArresterMcov != \"\" && $ArresterRating != \"\") {$querystring = \"select * from all_arr where (Type like \'$ArresterType%\') and (Mcov between $MinArrMcov and $MaxArrMcov) and (Rating between $MinArrRating and $MaxArrRating) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\";}

   if ($ArresterCreep == \"\" && $ArresterMcov != \"\" && $ArresterRating == \"\") {$querystring = \"select * from all_arr where (Type like \'$ArresterType%\') and (Mcov between $MinArrMcov and $MaxArrMcov) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\";}

   if ($ArresterCreep == \"\" && $ArresterMcov == \"\" && $ArresterRating != \"\") {$querystring = \"select * from all_arr where (Type like \'$ArresterType%\') and (Rating between $MinArrRating and $MaxArrRating) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\";}

   if ($ArresterCreep == \"\" && $ArresterMcov == \"\" && $ArresterRating == \"\") {$querystring = \"select * from all_arr where (Type like \'$ArresterType%\') and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\";}

   $ArresterSearchMatch = mysql_query ($querystring);

   if ($MatchRecordRow = mysql_fetch_array($ArresterSearchMatch)) {

      do{

         echo \"<TR><td>\".$MatchRecordRow[\'CatalogNumber\'].\"</TD>\";

         echo \"<td>\".$MatchRecordRow[\'Type\'].\"</TD><td>\".$MatchRecordRow[\'Mcov\'].\"</TD>\";

         echo \"<td>\".$MatchRecordRow[\'Rating\'].\"</TD><td>\".$MatchRecordRow[\'Creep\'].\"</TD>\";

         $Description = \'.\';if ($MatchRecordRow[\'Description\'] <> \'\') {$Description = $MatchRecordRow[\'Description\'];}echo \"<td>\".$Description.\"</TD>\";

         $Customer = \'.\';if ($MatchRecordRow[\'Customer\'] <> \'\') {$Customer = $MatchRecordRow[\'Customer\'];}echo \"<td>\".$Customer.\"</TD>\";

         $Stat = \'.\';if ($MatchRecordRow[\'Stat\'] <> \'\') {$Stat = $MatchRecordRow[\'Stat\'];}echo \"<td>\".$Stat.\"</TD>\";

         $ArresterMultiRated = \'.\';if ($MatchRecordRow[\'MultiRated\'] == \'TRUE\') {$ArresterMultiRated = \'YES\';}echo \"<td>\".$ArresterMultiRated.\"</TD>\";

         $FirstUnit = \'.\';$SecondUnit = \'.\';$ThirdUnit = \'.\';$ForthUnit = \'.\';

         if ($ArresterMultiRated == \'YES\') {

                  if ($MatchRecordRow[\'FirstMcov\'] <> \'0\') {$FirstUnit = $MatchRecordRow[\'FirstMcov\'];}

                  if ($MatchRecordRow[\'SecondMcov\'] <> \'0\') {$SecondUnit = $MatchRecordRow[\'SecondMcov\'];}

                  if ($MatchRecordRow[\'ThirdMcov\'] <> \'0\') {$ThirdUnit = $MatchRecordRow[\'ThirdMcov\'];}

                  if ($MatchRecordRow[\'Forth\'] <> \'0\') {$ForthUnit = $MatchRecordRow[\'Forth\'];}

          }

      echo \"<td>\".$FirstUnit.\"</TD><td>\".$SecondUnit.\"</TD>\";echo \"<td>\".$ThirdUnit.\"</TD><td>\".$ForthUnit.\"</TD>\";

      $ArresterColor = \'.\';if ($MatchRecordRow[\'Color\'] <> \'\') {$ArresterColor = $MatchRecordRow[\'Color\'];}echo \"<td>\".$ArresterColor.\"</TD></TR>\";}

   while($MatchRecordRow = mysql_fetch_array($ArresterSearchMatch));}

   else {echo \"<center>Sorry, No Records Were Found!</center>\";}

   echo \"</table>\";

   echo \"<P><font size=\'8\' color=\'#000000\'><H2 align=center>Search Completed</H2></font>\";

} Else {echo \"<center><H1>Please Select MultiRated <font size=\'8\' color=\'red\'>[True]</font> or <font size=\'8\' color=\'red\'>[False]</font></h1></center>\";DataEntryForm();}

mysql_free_result($ArresterSearchMatch);

}

 

switch($_REQUEST[\'cmd\']){

   default;

   SearchRecordReturnMatch($_POST[\'ArresterType\'],$_POST[\'ArresterMcov\'],$_POST[\'ArresterRating\'],$_POST[\'ArresterCreep\'],$_POST[\'ArresterDescription\'],$_POST[\'ArresterMultiRated\']);

   break;

}

?>

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8077
Share on other sites

page2.php Part 2

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]   if ($ArresterCreep != \\\"\\\" && $ArresterMcov != \\\"\\\" && $ArresterRating != \\\"\\\") {$querystring = \\\"select * from all_arr where (Type like \'$ArresterType%\') and (Mcov between $MinArrMcov and $MaxArrMcov) and (Rating between $MinArrRating and $MaxArrRating) and (Creep between $MinArrCrp and $MaxArrCrp) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\\\";}

   if ($ArresterCreep != \\\"\\\" && $ArresterMcov != \\\"\\\" && $ArresterRating == \\\"\\\") {$querystring = \\\"select * from all_arr where (Type like \'$ArresterType%\') and (Mcov between $MinArrMcov and $MaxArrMcov) and (Creep between $MinArrCrp and $MaxArrCrp) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\\\";}

   if ($ArresterCreep != \\\"\\\" && $ArresterMcov == \\\"\\\" && $ArresterRating == \\\"\\\") {$querystring = \\\"select * from all_arr where (Type like \'$ArresterType%\') and (Creep between $MinArrCrp and $MaxArrCrp) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\\\";}

   if ($ArresterCreep != \\\"\\\" && $ArresterMcov == \\\"\\\" && $ArresterRating != \\\"\\\") {$querystring = \\\"select * from all_arr where (Type like \'$ArresterType%\') and (Rating between $MinArrRating and $MaxArrRating) and (Creep between $MinArrCrp and $MaxArrCrp) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\\\";}

   if ($ArresterCreep == \\\"\\\" && $ArresterMcov != \\\"\\\" && $ArresterRating != \\\"\\\") {$querystring = \\\"select * from all_arr where (Type like \'$ArresterType%\') and (Mcov between $MinArrMcov and $MaxArrMcov) and (Rating between $MinArrRating and $MaxArrRating) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\\\";}

   if ($ArresterCreep == \\\"\\\" && $ArresterMcov != \\\"\\\" && $ArresterRating == \\\"\\\") {$querystring = \\\"select * from all_arr where (Type like \'$ArresterType%\') and (Mcov between $MinArrMcov and $MaxArrMcov) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\\\";}

   if ($ArresterCreep == \\\"\\\" && $ArresterMcov == \\\"\\\" && $ArresterRating != \\\"\\\") {$querystring = \\\"select * from all_arr where (Type like \'$ArresterType%\') and (Rating between $MinArrRating and $MaxArrRating) and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\\\";}

   if ($ArresterCreep == \\\"\\\" && $ArresterMcov == \\\"\\\" && $ArresterRating == \\\"\\\") {$querystring = \\\"select * from all_arr where (Type like \'$ArresterType%\') and (Description like\'%$ArresterDescription%\') and (MultiRated like \'$ArresterMultiRated\') order by Creep,CatalogNumber\\\";}

   $ArresterSearchMatch = mysql_query ($querystring);

   if ($MatchRecordRow = mysql_fetch_array($ArresterSearchMatch)) {

      do{

         echo \\\"<TR><td>\\\".$MatchRecordRow[\'CatalogNumber\'].\\\"</TD>\\\";

         echo \\\"<td>\\\".$MatchRecordRow[\'Type\'].\\\"</TD><td>\\\".$MatchRecordRow[\'Mcov\'].\\\"</TD>\\\";

         echo \\\"<td>\\\".$MatchRecordRow[\'Rating\'].\\\"</TD><td>\\\".$MatchRecordRow[\'Creep\'].\\\"</TD>\\\";

         $Description = \'.\';if ($MatchRecordRow[\'Description\'] <> \'\') {$Description = $MatchRecordRow[\'Description\'];}echo \\\"<td>\\\".$Description.\\\"</TD>\\\";

         $Customer = \'.\';if ($MatchRecordRow[\'Customer\'] <> \'\') {$Customer = $MatchRecordRow[\'Customer\'];}echo \\\"<td>\\\".$Customer.\\\"</TD>\\\";

         $Stat = \'.\';if ($MatchRecordRow[\'Stat\'] <> \'\') {$Stat = $MatchRecordRow[\'Stat\'];}echo \\\"<td>\\\".$Stat.\\\"</TD>\\\";

         $ArresterMultiRated = \'.\';if ($MatchRecordRow[\'MultiRated\'] == \'TRUE\') {$ArresterMultiRated = \'YES\';}echo \\\"<td>\\\".$ArresterMultiRated.\\\"</TD>\\\";

         $FirstUnit = \'.\';$SecondUnit = \'.\';$ThirdUnit = \'.\';$ForthUnit = \'.\';

         if ($ArresterMultiRated == \'YES\') {

                  if ($MatchRecordRow[\'FirstMcov\'] <> \'0\') {$FirstUnit = $MatchRecordRow[\'FirstMcov\'];}

                  if ($MatchRecordRow[\'SecondMcov\'] <> \'0\') {$SecondUnit = $MatchRecordRow[\'SecondMcov\'];}

                  if ($MatchRecordRow[\'ThirdMcov\'] <> \'0\') {$ThirdUnit = $MatchRecordRow[\'ThirdMcov\'];}

                  if ($MatchRecordRow[\'Forth\'] <> \'0\') {$ForthUnit = $MatchRecordRow[\'Forth\'];}

          }

      echo \\\"<td>\\\".$FirstUnit.\\\"</TD><td>\\\".$SecondUnit.\\\"</TD>\\\";echo \\\"<td>\\\".$ThirdUnit.\\\"</TD><td>\\\".$ForthUnit.\\\"</TD>\\\";

      $ArresterColor = \'.\';if ($MatchRecordRow[\'Color\'] <> \'\') {$ArresterColor = $MatchRecordRow[\'Color\'];}echo \\\"<td>\\\".$ArresterColor.\\\"</TD></TR>\\\";}

   while($MatchRecordRow = mysql_fetch_array($ArresterSearchMatch));}

   else {echo \\\"<center>Sorry, No Records Were Found!</center>\\\";}

   echo \\\"</table>\\\";

   echo \\\"<P><font size=\'8\' color=\'#000000\'><H2 align=center>Search Completed</H2></font>\\\";

} Else {echo \\\"<center><H1>Please Select MultiRated <font size=\'8\' color=\'red\'>[True]</font> or <font size=\'8\' color=\'red\'>[False]</font></h1></center>\\\";DataEntryForm();}

mysql_free_result($ArresterSearchMatch);

}

 

switch($_REQUEST[\'cmd\']){

   default;

   SearchRecordReturnMatch($_POST[\'ArresterType\'],$_POST[\'ArresterMcov\'],$_POST[\'ArresterRating\'],$_POST[\'ArresterCreep\'],$_POST[\'ArresterDescription\'],$_POST[\'ArresterMultiRated\']);

   break;

}

?>[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

263342[/snapback]

 

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8082
Share on other sites

ok thanks do u have on with listboxes and other types of fields instead of textboxes...or does it really matter.....

ex: goto my page 

nightspotz.com

264345[/snapback]

It does not matter you still have to set the Name on the list box.

 

The only difference is the root code on the input page

 

Text Box for user input

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]echo \"<form action=query.php method=post>\";

echo \"Originator: <INPUT maxLength=50 name=Originator>\";

echo \"<input type=submit name=cmd value=\'Search Records\'>\";

echo \"</FORM>\";[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

List Box feed from database for user select

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]$querystring = \"select User_Name,Submitter from tbluser Order by Submitter ASC\";

$SearchMatch = mysql_query ($querystring);

echo \"<form action=query.php method=post>\";

echo \"<select name=Originator>\";

echo \"<option></option>\";

if ($MatchRecordRow = mysql_fetch_array($SearchMatch)) {

    do{

        echo \"<option value=\'\".$MatchRecordRow[\'Submitter\'].\"\'>\".$MatchRecordRow[\'Submitter\'].\"</option>\";

       }

    while($MatchRecordRow = mysql_fetch_array($SearchMatch));

}

echo \"</select>\";

echo \"<input type=submit name=cmd value=\'Search Records\'>\";

echo \"</FORM>\";[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

They are both named Originator either one can be used to get the data.

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8097
Share on other sites

ok i'm getting an error message:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/nightsp/public_html/testcode.php on line 38

 

Sorry, No Records Were Found!

 

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home2/nightsp/public_html/testcode.php on line 46

 

 

and here is the code can you read the notes i put in please thanks, i greatly appreciate this:

by the way $AG = $_POST[agegroup], $VT = $_POST[venuetype]

$MT = $_POST[musictype]; are list boxes as u can see on the page nightspotz.com

 

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]

[span style=\"color:#0000BB\"]<?php

$VN [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]venuename[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]areacode[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]agegroup[/span][span style=\"color:#007700\"]];

 

[/span][span style=\"color:#FF8000\"]//-----HOW DO I ADD THESE TO VARIBLES TO THE QUERY FROM MY SEARCH FORM---------

[/span][span style=\"color:#0000BB\"]$VT [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]venuetype[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$MT [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]musictype[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#FF8000\"]//-----------------------------------------------------

[/span][span style=\"color:#0000BB\"]  

$HostID [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]localhost[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$UserID [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][*******];

[/span][span style=\"color:#0000BB\"]$PassID [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][*******];

[/span][span style=\"color:#0000BB\"]$dbname [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][********];

[/span][span style=\"color:#0000BB\"]$Table [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]venues[/span][span style=\"color:#007700\"]];

 

 

[/span][span style=\"color:#FF8000\"]//----------CAN I TAKE THIS TABLE OUT OR WAS THIS JUST TO ECHO AND SEE IF IT WORKS..I DONT NEED ANY OF

//---THESE TABLES I\'LL FORMAT IT IN DREAMWEAVER BUT CAN U SHOW ME HOW TO JUST GET THE RESULTS WITH THE

//----PHP ICON SO I CAN JUST POSITION THEM IN DREAMWEAVER...THANKS...

[/span][span style=\"color:#007700\"]echo [/span][span style=\"color:#DD0000\"]\"<TABLE BORDER=1 align=center>\"[/span][span style=\"color:#007700\"];

echo [/span][span style=\"color:#DD0000\"]\"<TD>First Name</TD><TD>Last Name</TD><TD>Street Address</TD><TD>City</TD><TD>State</TD><TR>\"[/span][span style=\"color:#007700\"];

echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$VN[/span][span style=\"color:#007700\"].[/span][span style=\"color:#DD0000\"]\"</td><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$AC[/span][span style=\"color:#007700\"].[/span][span style=\"color:#DD0000\"]\"</td><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$AG[/span][span style=\"color:#007700\"].[/span][span style=\"color:#DD0000\"]\"</td>\"[/span][span style=\"color:#007700\"];

echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$City[/span][span style=\"color:#007700\"].[/span][span style=\"color:#DD0000\"]\"</td><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$State[/span][span style=\"color:#007700\"].[/span][span style=\"color:#DD0000\"]\"</td>\"[/span][span style=\"color:#007700\"];

echo [/span][span style=\"color:#DD0000\"]\"</TR></table><p>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#FF8000\"]//---------------------------------------------------------------------------------------------

 

[/span][span style=\"color:#0000BB\"]mysql_select_db [/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$dbname[/span][span style=\"color:#007700\"]);

[/span][span style=\"color:#0000BB\"]$mysql_mylink [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_pconnect[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$HostID[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$UserID[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$PassID[/span][span style=\"color:#007700\"]);

echo [/span][span style=\"color:#DD0000\"]\"<TABLE class=\'sortable\' id=\'Identify\' BORDER=1 align=center>\"[/span][span style=\"color:#007700\"];

echo [/span][span style=\"color:#DD0000\"]\"<TD>VENUENAME</TD><TD>AREACODE</TD><TD>Street Address</TD><TD>city</TD><TD>state</TD>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"select * from \'$Table\'\"[/span][span style=\"color:#007700\"];

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\"where (venuename like \'%$VN%\') and (areacode like \'%$AC%\') and (agegroup like \'%$AG%\')\"[/span][span style=\"color:#007700\"];}

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\"where (venuename like \'%$VN%\') and (areacode like \'%$AC%\')\"[/span][span style=\"color:#007700\"];}

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\"where (venuename like \'%$VN%\')\"[/span][span style=\"color:#007700\"];}

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\"where (venuename like \'%$VN%\') and (agegroup like \'%$AG%\')\"[/span][span style=\"color:#007700\"];}

[/span][span style=\"color:#0000BB\"]$SearchMatch [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query [/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$querystring[/span][span style=\"color:#007700\"]);

if ([/span][span style=\"color:#0000BB\"]$MatchRecordRow [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"])) {

[/span][span style=\"color:#0000BB\"]   do[/span][span style=\"color:#007700\"]{

[/span][span style=\"color:#0000BB\"]      echo [/span][span style=\"color:#DD0000\"]\"<TR><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'venuename\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]      echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'areacode\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'agegroup\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]      echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'city\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'state\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

} while([/span][span style=\"color:#0000BB\"]$MatchRecordRow [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"]));

} else {echo [/span][span style=\"color:#DD0000\"]\"<center>Sorry, No Records Were Found!</center>\"[/span][span style=\"color:#007700\"];}

echo [/span][span style=\"color:#DD0000\"]\"</table>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]mysql_free_result[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"]);

[/span][span style=\"color:#0000BB\"]?>[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8098
Share on other sites

ok i fixed some of the problems but now the the variables arent working because i cant do any type of search i can only hit submit but i think the SQL qyery is jacked up can you help with this i want the viewers to be able to search by using 1 or all of the search fields to narrow the search down.....

here is the working form...

http://www.nightspotz.com/testsearch.php

can you go and check it out

oh by the way the mistake was

$querystring = "select * from '$Table'";

had to get rid of the ' ' around the $Table.....

can you help with the rest please...you dont know how much of a relief this is...

 

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]

[span style=\"color:#0000BB\"]<?php

$VN [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]venuename[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]areacode[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]agegroup[/span][span style=\"color:#007700\"]];

 

[/span][span style=\"color:#FF8000\"]//-----HOW DO I ADD THESE TO VARIBLES TO THE QUERY FROM MY SEARCH FORM---------

[/span][span style=\"color:#0000BB\"]$VT [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]venuetype[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$MT [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]musictype[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#FF8000\"]//-----------------------------------------------------

 

 

[/span][span style=\"color:#0000BB\"]$mysql_mylink [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_pconnect[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]localhost[/span][span style=\"color:#007700\"], *****, *****) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

[/span][span style=\"color:#0000BB\"]mysql_select_db [/span][span style=\"color:#007700\"](********) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

echo [/span][span style=\"color:#DD0000\"]\"<TABLE class=\'sortable\' id=\'Identify\' BORDER=1 align=center>\"[/span][span style=\"color:#007700\"];

echo [/span][span style=\"color:#DD0000\"]\"<TD>VENUENAME</TD><TD>AREACODE</TD><TD>AGE GROUP</TD><TD>CITY</TD><TD>STATE</TD>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"select * from venues\"[/span][span style=\"color:#007700\"];

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\"where (venuename like \'%$VN%\') and (areacode like \'%$AC%\') and (agegroup like \'%$AG%\')\"[/span][span style=\"color:#007700\"];}

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\"where (venuename like \'%$VN%\') and (areacode like \'%$AC%\')\"[/span][span style=\"color:#007700\"];}

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\"where (venuename like \'%$VN%\')\"[/span][span style=\"color:#007700\"];}

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]&& [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\"where (venuename like \'%$VN%\') and (agegroup like \'%$AG%\')\"[/span][span style=\"color:#007700\"];}

[/span][span style=\"color:#0000BB\"]$SearchMatch [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query [/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$querystring[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$mysql_mylink[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

if ([/span][span style=\"color:#0000BB\"]$MatchRecordRow [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"])) {

   do{

      echo [/span][span style=\"color:#DD0000\"]\"<TR><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'venuename\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

      echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'areacode\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'agegroup\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

      echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'city\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'state\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

} while([/span][span style=\"color:#0000BB\"]$MatchRecordRow [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"]));

} else {echo [/span][span style=\"color:#DD0000\"]\"<center>Sorry, No Records Were Found!</center>\"[/span][span style=\"color:#007700\"];}

echo [/span][span style=\"color:#DD0000\"]\"</table>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]mysql_free_result[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"]);

[/span][span style=\"color:#0000BB\"]?>

[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8100
Share on other sites

Ok I see one thing where in the query string you would need a space built in string

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]$querystring = \"select * from venues\";

if ($VN != \"\" && $AC != \"\" && $AG != \"\") {$querystring = $guerystring + \"where (venuename like \'%$VN%\') and (areacode like \'%$AC%\') and (agegroup like \'%$AG%\')\";}

if ($VN != \"\" && $AC != \"\" && $AG == \"\") {$querystring = $guerystring + \"where (venuename like \'%$VN%\') and (areacode like \'%$AC%\')\";}

if ($VN != \"\" && $AC == \"\" && $AG == \"\") {$querystring = $guerystring + \"where (venuename like \'%$VN%\')\";}

if ($VN != \"\" && $AC == \"\" && $AG != \"\") {$querystring = $guerystring + \"where (venuename like \'%$VN%\') and (agegroup like \'%$AG%\')\";} [/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

Like this

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]$querystring = \"select * from venues\";

$querystring = $guerystring +\" where (venuename like \'%$VN%\')\";}[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

Otherwise your string will look like this on add

select * from venueswhere (venuename like '%$VN%')

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8101
Share on other sites

ok here is my code but im getting an error:

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '0' at line 1

 

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]

[span style=\"color:#0000BB\"]<?php

$VN [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]venuename[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]areacode[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]agegroup[/span][span style=\"color:#007700\"]];

 

[/span][span style=\"color:#FF8000\"]//-----HOW DO I ADD THESE TO VARIBLES TO THE QUERY FROM MY SEARCH FORM---------

[/span][span style=\"color:#0000BB\"]$VT [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]venuetype[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$MT [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]musictype[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#FF8000\"]//-----------------------------------------------------

 

 

[/span][span style=\"color:#0000BB\"]$mysql_mylink [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_pconnect[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"localhost\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"nightsp\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"babystuff\"[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

[/span][span style=\"color:#0000BB\"]mysql_select_db [/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]nightsp_nightspotz[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

echo [/span][span style=\"color:#DD0000\"]\"<TABLE class=\'sortable\' id=\'Identify\' BORDER=1 align=center>\"[/span][span style=\"color:#007700\"];

echo [/span][span style=\"color:#DD0000\"]\"<TD>VENUENAME</TD><TD>AREACODE</TD><TD>AGE GROUP</TD><TD>CITY</TD><TD>STATE</TD>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"select * from venues\"[/span][span style=\"color:#007700\"];

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]!=[/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\"where (venuename like \'%$VN%\') \"[/span][span style=\"color:#007700\"];}

 

if ([/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]!=[/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\"and (areacode like \'%$AC%\') \"[/span][span style=\"color:#007700\"];}

 

if ([/span][span style=\"color:#0000BB\"]$AG[/span][span style=\"color:#007700\"]!=[/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\"and (agegroup like \'%$AG%\')\"[/span][span style=\"color:#007700\"];}

 

 

[/span][span style=\"color:#0000BB\"]$SearchMatch [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query [/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$querystring[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$mysql_mylink[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

if ([/span][span style=\"color:#0000BB\"]$MatchRecordRow [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"])) {

   do{

      echo [/span][span style=\"color:#DD0000\"]\"<TR><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'venuename\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

      echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'areacode\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'agegroup\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

      echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'city\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'state\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

} while([/span][span style=\"color:#0000BB\"]$MatchRecordRow [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"]));

} else {echo [/span][span style=\"color:#DD0000\"]\"<center>Sorry, No Records Were Found!</center>\"[/span][span style=\"color:#007700\"];}

echo [/span][span style=\"color:#DD0000\"]\"</table>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]mysql_free_result[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"]);

 

[/span][span style=\"color:#0000BB\"]?>

[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

 

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8108
Share on other sites

Clause for each type of match needs to be added and spacing in the right place in the case (Below) the space will be added at the addition of the second part of the string [ Where......]

 

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]

[span style=\"color:#0000BB\"]<?php

$VN [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]venuename[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]areacode[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]agegroup[/span][span style=\"color:#007700\"]];

 

[/span][span style=\"color:#FF8000\"]//-----HOW DO I ADD THESE TO VARIBLES TO THE QUERY FROM MY SEARCH FORM---------

[/span][span style=\"color:#0000BB\"]$VT [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]venuetype[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$MT [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]musictype[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#FF8000\"]//-----------------------------------------------------

[/span][span style=\"color:#0000BB\"]$mysql_mylink [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_pconnect[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"localhost\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"nightsp\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"babystuff\"[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

[/span][span style=\"color:#0000BB\"]mysql_select_db [/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]nightsp_nightspotz[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

echo [/span][span style=\"color:#DD0000\"]\"<TABLE class=\'sortable\' id=\'Identify\' BORDER=1 align=center>\"[/span][span style=\"color:#007700\"];

echo [/span][span style=\"color:#DD0000\"]\"<TD>VENUENAME</TD><TD>AREACODE</TD><TD>AGE GROUP</TD><TD>CITY</TD><TD>STATE</TD>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"select * from venues\"[/span][span style=\"color:#007700\"];

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\" where (venuename like \'%$VN%\')\"[/span][span style=\"color:#007700\"];}

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\" where (venuename like \'%$VN%\') AND (areacode like \'%$AC%\')\"[/span][span style=\"color:#007700\"];}

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\" where (venuename like \'%$VN%\') AND (agegroup like \'%$AG%\')\"[/span][span style=\"color:#007700\"];}

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\" where (areacode like \'%$AC%\')\"[/span][span style=\"color:#007700\"];}

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\" where (areacode like \'%$AC%\') AND (agegroup like \'%$AG%\')\"[/span][span style=\"color:#007700\"];}

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]!= [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$guerystring [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#DD0000\"]\" where (agegroup like \'%$AG%\')\"[/span][span style=\"color:#007700\"];}

if ([/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#007700\"]AND [/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"]) {}

[/span][span style=\"color:#0000BB\"]$SearchMatch [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query [/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$querystring[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$mysql_mylink[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

if ([/span][span style=\"color:#0000BB\"]$MatchRecordRow [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"])) {

[/span][span style=\"color:#0000BB\"]   do[/span][span style=\"color:#007700\"]{

[/span][span style=\"color:#0000BB\"]      echo [/span][span style=\"color:#DD0000\"]\"<TR><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'venuename\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]      echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'areacode\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'agegroup\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]      echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'city\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'state\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

} while([/span][span style=\"color:#0000BB\"]$MatchRecordRow [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"]));

} else {echo [/span][span style=\"color:#DD0000\"]\"<center>Sorry, No Records Were Found!</center>\"[/span][span style=\"color:#007700\"];}

echo [/span][span style=\"color:#DD0000\"]\"</table>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]mysql_free_result[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"]);

 

[/span][span style=\"color:#0000BB\"]?>[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

265132[/snapback]

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8110
Share on other sites

i'm trying to make a form with multiple text and list menus that query a MySQL database with PHP......can anyone give me an example with multiple fields of one of a tutorial that may help me accomplish this, preferrably one that i can do it with the help of dreamweaver....and also i need to make it were the search results primary ex. venue name is an hyperlink to a detailed page....so the viewers can get more information about the venue.....or topic searching for....

263324[/snapback]

 

 

The things are not quite so complicated! Try smth like that:

 

$QueryString = "SELECT * FROM table_name ";

if (isset($_POST['your_form_field'])) {
 $Crt = $_POST['your_form_field'];
 $QueryString .= " WHERE table_field LIKE %\"$Crt\"%";
}

 

You use such "if" statements for all your search criterias, to build up a dynamic SQL Query.

 

After you finished, try to run the query.

 

Enjoy

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8111
Share on other sites

is this !@#$ really this hard or what, come on y aint this !@#$ working can anybody help im getting to !@#$ frustrated....all i want to do is make a search page with different search fields that narrow down a search to a viewer....!@#$

has anbody on here ever made a search page with more thatn 1 field.....

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8131
Share on other sites

what would $CRT be

 

 

 

The things are not quite so complicated! Try smth like that:

 

$QueryString = "SELECT * FROM table_name ";

if (isset($_POST['your_form_field'])) {
 $Crt = $_POST['your_form_field'];
 $QueryString .= " WHERE table_field LIKE %\"$Crt\"%";
}

 

You use such "if" statements for all your search criterias, to build up a dynamic SQL Query.

 

After you finished, try to run the query.

 

Enjoy

265264[/snapback]

 

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8132
Share on other sites

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]

$VN = $_POST[venuename];

$AC = $_POST[areacode];

$AG = $_POST[agegroup];

 

//-----HOW DO I ADD THESE TO VARIBLES TO THE QUERY FROM MY SEARCH FORM---------

$VT = $_POST[venuetype];

$MT = $_POST[musictype]; [/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

Are your values passing.

 

have you checked that????????????????????????????????

 

if the query returns no records found.

 

Echo the variables to the screen just to see it the values are right to what you think they should be.

 

And no it is not hard if things are passed right.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8142
Share on other sites

venuename is the database column

txtVenuename is the form_field

$VT = $_POST['txtVenuename']

 

so it should look like this:

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]

[span style=\"color:#0000BB\"]<?php

$VN [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]venuename[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$AC [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]areacode[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$AG [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]agegroup[/span][span style=\"color:#007700\"]];

 

[/span][span style=\"color:#FF8000\"]//-----HOW DO I ADD THESE TO VARIBLES TO THE QUERY FROM MY SEARCH FORM---------

[/span][span style=\"color:#0000BB\"]$VT [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]venuetype[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$MT [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]musictype[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#FF8000\"]//-----------------------------------------------------

 

 

[/span][span style=\"color:#0000BB\"]$mysql_mylink [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_pconnect[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"localhost\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"nightsp\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"babystuff\"[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

[/span][span style=\"color:#0000BB\"]mysql_select_db [/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]nightsp_nightspotz[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

echo [/span][span style=\"color:#DD0000\"]\"<TABLE class=\'sortable\' id=\'Identify\' BORDER=1 align=center>\"[/span][span style=\"color:#007700\"];

echo [/span][span style=\"color:#DD0000\"]\"<TD>VENUENAME</TD><TD>AREACODE</TD><TD>AGE GROUP</TD><TD>CITY</TD><TD>STATE</TD>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"SELECT * FROM venues_new\"[/span][span style=\"color:#007700\"];

 

if (isset([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'txtVenuename\'[/span][span style=\"color:#007700\"]])) {

[/span][span style=\"color:#0000BB\"]$VN [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'txtVenuename\'[/span][span style=\"color:#007700\"]];

[/span][span style=\"color:#0000BB\"]$querystring [/span][span style=\"color:#007700\"].= [/span][span style=\"color:#DD0000\"]\" WHERE venuename LIKE %\\"[/span][span style=\"color:#0000BB\"]$VT[/span][span style=\"color:#007700\"]&[/span][span style=\"color:#FF8000\"]#092;\"%\";

[/span][span style=\"color:#007700\"]}

 

[/span][span style=\"color:#0000BB\"]$SearchMatch [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query [/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$querystring[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$mysql_mylink[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

if ([/span][span style=\"color:#0000BB\"]$MatchRecordRow [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"])) {

   do{

      echo [/span][span style=\"color:#DD0000\"]\"<TR><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'venuename\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

      echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'areacode\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'agegroup\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

      echo [/span][span style=\"color:#DD0000\"]\"<td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'city\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD><td>\"[/span][span style=\"color:#007700\"].[/span][span style=\"color:#0000BB\"]$MatchRecordRow[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'state\'[/span][span style=\"color:#007700\"]].[/span][span style=\"color:#DD0000\"]\"</TD>\"[/span][span style=\"color:#007700\"];

} while([/span][span style=\"color:#0000BB\"]$MatchRecordRow [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"]));

} else {echo [/span][span style=\"color:#DD0000\"]\"<center>Sorry, No Records Were Found!</center>\"[/span][span style=\"color:#007700\"];}

echo [/span][span style=\"color:#DD0000\"]\"</table>\"[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]mysql_free_result[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$SearchMatch[/span][span style=\"color:#007700\"]);

 

[/span][span style=\"color:#0000BB\"]?>

[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

Link to comment
https://forums.phpfreaks.com/topic/2438-multifield-form-search/#findComment-8152
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.