TechMistress Posted October 8, 2009 Share Posted October 8, 2009 Hi All, I could use some help on this code I wrote, but won't work. It's for an event listing. This block is code for the filters for the events. All filters are marked YES in the database, but the location and venue filters won't work. When selected, the page just reloads. The dropdowns are populated with the existing entries in the database. # filter settings $fil_query = "select variable, value from cpt_settings where variable like 'filter_%'"; $fil_rs = mysql_query($fil_query); $filters = array(); $col_ct = 0; while ($fil_row = mysql_fetch_array($fil_rs)) { $filters[$fil_row['variable']] = $fil_row['value']; if ($fil_row['value'] == "Y") { $col_ct++; } } ?> <table border="0" cellspacing="0" cellpadding="0"> <form name="s2" method="post" action=""> <tr><td colspan="<?=$col_ct ?>" align="right" class="subnav"> <p align="left"><strong>Filter Events by</strong>: </td></tr> <tr valign="top"> <? if($filters['filter_cat'] == "Y") { ?> <td align="left" class="subnav"><?=$typeselect ?></td> <? } ?> <? if($filters['filter_loc'] == "Y") { ?> <td align="left" class="subnav"><?=$locationselect ?></td> <? } ?> <? if($filters['filter_ven'] == "Y") { ?> <td align="left" class="subnav"><?=$venueselect ?></td> <? } ?> <? if ($col_ct > 3) { ?></tr><tr><? } ?> <? if($filters['filter_day'] == "Y") { ?> <td align="left" class="subnav"><?=$dayselect ?></td> <? } ?> <? if($filters['filter_month'] == "Y") { ?> <td align="left" class="subnav"><?=$monthselect ?></td> <? } ?> <? if($filters['filter_keyword'] == "Y") { ?> <td align="left" class="subnav"><?=$keywordbox ?></td> <? } ?> </tr> <tr><td colspan="<?=$col_ct ?>"><input type=submit value="Go"></td></tr> </form> </table> Quote Link to comment https://forums.phpfreaks.com/topic/176997-whats-going-wrong-php-help-needed/ Share on other sites More sharing options...
GKWelding Posted October 9, 2009 Share Posted October 9, 2009 Can you post more from the start of your code as this will assist me in helping you. Anything before #filter settings will help. Quote Link to comment https://forums.phpfreaks.com/topic/176997-whats-going-wrong-php-help-needed/#findComment-933772 Share on other sites More sharing options...
RussellReal Posted October 9, 2009 Share Posted October 9, 2009 What exactly is the problem? Quote Link to comment https://forums.phpfreaks.com/topic/176997-whats-going-wrong-php-help-needed/#findComment-933775 Share on other sites More sharing options...
GKWelding Posted October 9, 2009 Share Posted October 9, 2009 I think, basically, the problem is the filters aren't working as the LIKE isn't being formatted properly and all of the entries are being returned, if I read the original post correctly. Quote Link to comment https://forums.phpfreaks.com/topic/176997-whats-going-wrong-php-help-needed/#findComment-933778 Share on other sites More sharing options...
TechMistress Posted October 9, 2009 Author Share Posted October 9, 2009 The code I presented was an included file just before this code: (i know, it's not pretty) <tr><td align="left" class="subnav"></td><td align="right" class="subnav"></td><td align="right" class="subnav"><?=$navigate ?></td></tr></table><? $i = 1;while (($events = mysql_fetch_array($eventList)) && $i <= $eventsperpage) {?><table border="0" cellspacing="2" cellpadding="3" width="98%"><? if ($sort == "date") { if ($events["eventDate"] != $last_date) { $last_date = $events["eventDate"];?><tr> <td colspan="2" class="eventHead" align=center><?=strftime("%A, %B %d",strtotime($last_date)) ?></td></tr><? }} ?><tr> <td colspan="2" class="eventHead"><?=$events["eventTitle"] ?></td></tr><tr> <td valign="top"><table width="98%" border="0" cellspacing="0" cellpadding="0"> <tr align="left" valign="top"> <td class="eventText" wdith="60"><strong>Date:</strong> </td> <td class="eventText"><?=strftime("%A, %B %d",strtotime($events["eventDate"])) ?> <? if($events["eventDateEnd"] != "0000-00-00" and $events["eventDateEnd"] != $events["eventDate"] and $events["eventDateEnd"] != ""){ echo " -<br>".strftime("%A, %B %d",strtotime($events["eventDateEnd"])); } ?></td> </tr> <tr align="left" valign="top"> <td class="eventText"><strong>Time:</strong> </td> <td class="eventText"><? if ($events["eventStarthour"] > 0) { ?><?=$events["eventStarthour"] ?>:<?=$events["eventStartmin"] ?><?=$events["eventStartap"] ?><? } ?><? if ($events["eventEndhour"] > 0) { ?> - <?=$events["eventEndhour"] ?>:<?=$events["eventEndmin"] ?><?=$events["eventEndap"] ?><? } ?></td> </tr> <? if ($events["eventLocation"] <> "") { ?><tr align="left" valign="top"> <td class="eventText"><strong>Venue:</strong></td> <td class="eventText"><?=$events["eventVenue"] ?></td></tr><tr align="left" valign="top"> <td class="eventText"><strong>Location:</strong> </td> <td class="eventText"> <?=$events["eventLocation"] ?></td></tr><? } ?><? if ($events["eventCategory"] <> "") { ?> <tr align="left" valign="top"> <td class="eventText"><strong>Event Category:</strong> </td> <td class="eventText"><?=$events["eventCategory"] ?></td> </tr> <? } ?> <? if ($events["eventLink"] <> "") { ?> <tr align="left" valign="top"> <td class="eventText"><strong>For more info:</strong> </td> <td class="eventText"><strong><a href="<?=$events["eventLink"] ?>" target="_BLANK"><?=$events["eventLink"] ?></a></strong></td> </tr><? } ?> <? if ($events["event_mp3"] <> "") { ?> <tr align="left" valign="top"> <td class="eventText"><strong>MP3:</strong> </td> Quote Link to comment https://forums.phpfreaks.com/topic/176997-whats-going-wrong-php-help-needed/#findComment-933959 Share on other sites More sharing options...
TechMistress Posted October 12, 2009 Author Share Posted October 12, 2009 Ok, here are the queries. It's the location and the venue that aren't working or doing anything. Category(type) works fine. I checked the spelling and data names, all are fine. $typeselect .= "</select>"; #if($numtypes < 2) { # $typeselect = ""; #} $locationQuery = "SELECT DISTINCT eventLocation FROM events where userSubmitted = '0' ORDER BY eventLocation"; $locationList = mysql_query($locationQuery) or die(mysql_error()); $numtypes = mysql_num_rows($locationList); $locationselect = "<select name=\"location\" style=\"width:110px;\">"; if($location == "All"){ $all = "selected"; $locationfilter = ""; } else { if ($location <> "") { $locationfilter = "AND eventLocation='" . $location . "'"; } } $locationselect .= "<option value=\"All\" " . $all . ">All Locations</option>"; while($locationarray = mysql_fetch_array($locationList)){ if($locationarray["eventLocation"] != "") { $selected = ""; if($locationarray["eventLocation"] == $location) { $selected = "selected"; } $locationselect .= "<option value=\"" . $locationarray["eventLocation"] . "\" " . $selected . ">" . substr($locationarray["eventLocation"],0,15) . "</option>"; } } $locationselect .= "</select>"; #if($numtypes < 2) { # $locationselect = ""; #} $venueQuery = "SELECT DISTINCT eventVenue FROM events where userSubmitted = '0' ORDER BY eventVenue"; $venueList = mysql_query($venueQuery) or die(mysql_error()); $numtypes = mysql_num_rows($venueList); $venueselect = "<select name=\"venue\" style=\"width:110px;\">"; if($venue == "All"){ $all = "selected"; $venuefilter = ""; } else { if ($venue <> "") { $venuefilter = "AND eventVenue='" . $venue . "'"; } } $venueselect .= "<option value=\"All\" " . $all . ">All Venues</option>"; while($venuearray = mysql_fetch_array($venueList)){ if($venuearray["eventVenue"] != "") { $selected = ""; if($venuearray["eventVenue"] == $venue) { $selected = "selected"; } $venueselect .= "<option value=\"" . $venuearray["eventVenue"] . "\" " . $selected . ">" . $venuearray["eventVenue"] . "</option>"; } } $venueselect .= "</select>"; #if($numtypes < 2) { # $venueselect = ""; #} Quote Link to comment https://forums.phpfreaks.com/topic/176997-whats-going-wrong-php-help-needed/#findComment-935594 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.