I am pretty new to php/mysql so please bare with me please. I recently took over a project for a friend and I need some help with the way the site does its searches it is a basic directory site set up with php and mysql the database consists of 8 tables est_type, est_overview, est_detail, app_hours, daily_events, op_hours, and type_of_entertain. What I am trying to do is a couple of things but I will address this one first. I need to add a pull down menu (search by city) to a results page that pulls from the type_of_entertainment table the problem is there are no city listings in the type_of_entertainment table just the id, name, type_ent the city results are in the est_overvies table. I tried a couple of things but I do not know how to tie searches together and I think thats what I am missing (but really have no idea 😕 )
This is what I have for code in the header -
<?php
$Recordset1__MMColParam = "1";
if (isset($HTTP_GET_VARS["est_type"]))
{$Recordset1__MMColParam = $HTTP_GET_VARS["est_type"];}
?>
<?php
$sponsored__MMColParam = "1";
if (isset($HTTP_GET_VARS["est_type"]))
{$sponsored__MMColParam = $HTTP_GET_VARS["est_type"];}
?>
<?php
$Recordset1=$twincities->Execute("SELECT est_overview.est_id, est_overview.est_name, est_overview.est_street, est_overview.est_city, est_overview.est_state, est_overview.est_zip, est_overview.blurb, est_overview.street_phone FROM est_overview INNER JOIN type_of_est ON est_overview.est_id = type_of_est.est_id WHERE est_type = '" . ($Recordset1__MMColParam) . "' AND accnt_type = 'b' ORDER BY est_name ASC") or DIE($twincities->ErrorMsg());
$Recordset1_numRows=0;
$Recordset1__totalRows=$Recordset1->RecordCount();
?>
<?php
$sponsored=$twincities->Execute("SELECT est_overview.est_id, est_overview.est_name, est_overview.est_street, est_overview.est_city, est_overview.est_state, est_overview.est_zip, est_overview.est_phone,est_overview.blurb, est_overview.icon FROM est_overview INNER JOIN type_of_est ON est_overview.est_id = type_of_est.est_id WHERE est_type = '" . ($sponsored__MMColParam) . "' AND accnt_type = 'P' ORDER BY est_name ASC") or DIE($twincities->ErrorMsg());
$sponsored_numRows=0;
$sponsored__totalRows=$sponsored->RecordCount();
?>
<?php
$ent=$twincities->Execute("SELECT est_overview.est_id, est_overview.est_name, est_overview.accnt_type, est_overview.est_street, est_overview.est_city, est_overview.est_state, est_overview.est_zip, est_overview.est_phone, est_overview.blurb, type_of_entertain.type_of_ent FROM est_overview INNER JOIN type_of_entertain ON est_overview.est_id = type_of_entertain.est_id WHERE type_of_entertain.type_of_ent = 'type_of_ent' ORDER BY est_overview.est_name ASC") or DIE($twincities->ErrorMsg());
$ent_numRows=0;
$ent__totalRows=$ent->RecordCount();
?>
<?php
$bycity=$twincities->Execute("SELECT DISTINCT est_overview.est_city FROM est_overview INNER JOIN type_of_entertain ON est_overview.est_id = type_of_entertain.est_id WHERE type_of_entertain.type_of_ent = '" . ($bycity__MMColParam) . "' ORDER BY est_overview.est_city ASC") or DIE($twincities->ErrorMsg());
$bycity_numRows=0;
$bycity__totalRows=$bycity->RecordCount();
?>
<?php
$Repeat2__numRows = -1;
$Repeat2__index= 0;
$Recordset1_numRows = $Recordset1_numRows + $Repeat2__numRows;
?>
<?php
$Repeat1__numRows = -1;
$Repeat1__index= 0;
$sponsored_numRows = $sponsored_numRows + $Repeat1__numRows;
?>
<?php $MM_paramName = ""; ?>
<?php
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
// create the list of parameters which should not be maintained
$MM_removeList = "&index=";
if ($MM_paramName != "") $MM_removeList .= "&".strtolower($MM_paramName)."=";
$MM_keepURL="";
$MM_keepForm="";
$MM_keepBoth="";
$MM_keepNone="";
// add the URL parameters to the MM_keepURL string
reset ($HTTP_GET_VARS);
while (list ($key, $val) = each ($HTTP_GET_VARS)) {
$nextItem = "&".strtolower($key)."=";
if (!stristr($MM_removeList, $nextItem)) {
$MM_keepURL .= "&".$key."=".urlencode($val);
}
}
// add the URL parameters to the MM_keepURL string
if(isset($HTTP_POST_VARS)){
reset ($HTTP_POST_VARS);
while (list ($key, $val) = each ($HTTP_POST_VARS)) {
$nextItem = "&".strtolower($key)."=";
if (!stristr($MM_removeList, $nextItem)) {
$MM_keepForm .= "&".$key."=".urlencode($val);
}
}
}
// create the Form + URL string and remove the intial '&' from each of the strings
$MM_keepBoth = $MM_keepURL."&".$MM_keepForm;
if (strlen($MM_keepBoth) > 0) $MM_keepBoth = substr($MM_keepBoth, 1);
if (strlen($MM_keepURL) > 0) $MM_keepURL = substr($MM_keepURL, 1);
if (strlen($MM_keepForm) > 0) $MM_keepForm = substr($MM_keepForm, 1);
?>
and this is the form I am trying to do it with
<p> <font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">Your
search for</font><font color="#000000"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<? echo $est_type ?>
</font></b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">returned
these results: <br>
</font><font color="#666666"><i><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><br>
<form name="form2" method="get" action="entertainment_results2.php?">
<table width="100%" border="0">
<tr>
<td width="44%">
<p align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#336699"><b>
<input type="hidden" name="est_type" value="<? echo $est_type ?>">
</b><font color="#000000">Narrow your results by city:</font></font></p>
</td>
<td width="14%">
<div align="left">
<select name="est_city">
<?php
if ($bycity__totalRows > 0){
$bycity__index=0;
$bycity->MoveFirst();
WHILE ($bycity__index < $bycity__totalRows){
?>
<option value="<?php echo $bycity->Fields("est_city")?>">
<?php echo $bycity->Fields("est_city");?>
</option>
<?php
$bycity->MoveNext();
$bycity__index++;
}
$bycity__index=0;
$bycity->MoveFirst();
}
?>
</select>
</div>
</td>
<td width="42%">
<input type="submit" name="Submit2" value="Go!">
</td>
</tr>
</table>
</form>
</font></i></font></font>
<?php while (($Repeat2__numRows-- != 0) && (!$sponsored->EOF))
{
?>
I apologize for the long post but I am trying to be as detailed as possible in attemtp to not waste to much of anyones time. Any help is appreciated!
Thanks in advance
-Beatle