Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Drop Down Menu Filter Help

 
Reply to topic    Forum Index » Help View previous topic
View next topic
Drop Down Menu Filter Help
Author Message
eberswine



Joined: 26 Apr 2007
Posts: 148

Post Drop Down Menu Filter Help Reply with quote
I am using this code for a drop down menu "filter" option :
Code:
<?php
include '../head.php';
$sday[] = '';
$sday[0] = 'Day';

for ($i = 1; $i < 32; $i++){
   $sday[$i] = $i;
}

$smonth[] = '';
$smonth[0] = 'Month';
$month_names = array("1" => "January", "2" => "February", "3" => "March", "4" => "April", "5" => "May", "6" => "June", "7" => "July", "8" => "August", "9" => "September", "10" => "October", "11" => "November", "12" => "December", );

for ($i = 1; $i < 13; $i++){
   $smonth[$i] = $month_names[$i];
}

$syear[] = '';
$syear[0] = 'Year';

for ($i = 1996; $i < (date('Y') + 1); $i++){
   $syear[$i] = $i;
}
?>
---------------------
<form method="post" action="results.php" style="margin:0px; padding:0px">
<select name="category" ><option selected value="">Choose a Category</option>
<?
$custom_cats = array("10" => "All", "11" => "HS Track", "13" => "HS XC", "15" => "College Track", "16" => "College XC", "14" => "Road Race", "12" => "Trail Race", "17" => "Track", "18" => "XC", "19" => "Triathlon", "23" => "Duathlon",);

   foreach($custom_cats as $cat_id => $cat_name){
      echo '<option'.($category == $cat_id ? ' selected' : '').' value="'.$cat_id.'">'.$cat_name.'</option>';
   }
?>
</select>
<?=makeDropDown($smonth, 'month', 'Month'); ?>
<?=makeDropDown($sday, 'day', 'Day'); ?>
<?=makeDropDown($syear, 'year', 'Year'); ?>
<input name="Go" type="submit" id="Go" value="GO" />
</form>


And it works great. Just two questions:
1). I was wondering how I could make an error output if there is no search results? (instead of being blank)
2). If there was a way to keep the value in the select menu after the submit button is pressed? The Category Drop down menu keeps its value, but the Month, Day and Year go back to default???
Here is a picture after the action :



Thanks.
Fri Sep 12, 2008 5:14 am View user's profile Send private message
Guest








Please login to hide the ads.

FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2801
Location: Germany

Post Reply with quote
1. In your form you are linking to results.php. What's in this file?

2. Try this instead:
Code:
<?=makeDropDown($smonth, 'month', $_POST['month']); ?>
<?=makeDropDown($sday, 'day', $_POST['day']); ?>
<?=makeDropDown($syear, 'year', $_POST['year']); ?>

Fri Sep 12, 2008 1:44 pm View user's profile Send private message
eberswine



Joined: 26 Apr 2007
Posts: 148

Post Reply with quote
PERFECT!

1. In your form you are linking to results.php. What's in this file?

a- just an include code for results. I have a different include code for the index page.

Code:
<?php
   $category = '10';
   $number = '40';
   $template = 'results_justadded';
   if($_POST['category']){
   $category = $_POST['category'];
}
include $cutepath.'/show_news.php';   
?>

Fri Sep 12, 2008 4:04 pm View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2801
Location: Germany

Post Reply with quote
In inc/show.news.php add this:
Code:
if (!$query){
?>

<div class="error_message"><?=$echo['notFound']; ?></div>

<?
   return;
}


above:
Code:
foreach ($query as $bg => $row){

Thu Sep 18, 2008 6:16 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    Forum Index » Help All times are GMT + 1 Hour
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum



Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.