LJackson
09-06-2009, 09:11 PM
Hi All,
i have a form which i have set as a function as i require calling this form in several sections of my code, the problem im having is that one my main page i have a varible which is being used in my form function but it doesnt recognise its value?
here is my function
<?php
function store_filterForm(){
?>
<div class="form">
<form id="filter" action="stores.php" method="get">
<fieldset>
<div>
<div class="label">
<label for="cat_select">Category</label></div>
<select id="cat_select" name="cds">
<?php
print $category;
$options=array('entertainment','computing','electronics','clothing','health','misc');
foreach($options as $option) {
if($category==$option) {
echo "<option value=\"{$option}\" selected=\"selected\">{$option}</option>";
}
else {
echo "<option value=\"{$option}\">{$option}</option>";
}
}
?>
</select>
</div>
<div>
<div class="label">
<label for="filter_by">Filter By</label></div>
<select id="filter_by" name="filter_list">
<?php
$options=array('None','Name','Rating');
foreach($options as $option) {
if($b==$option) {
echo "<option value=\"{$option}\" selected=\"selected\">{$option}</option>";
}
else {
echo "<option value=\"{$option}\">{$option}</option>";
}
}
?>
</select>
</div>
<input type="submit" name="submit" id="submit" value="Filter" />
</fieldset>
</form>
</div>
<?php
}
?>
and the varible im trying to use is $category which i have tried printing out but nothing printed proving that the function is having trouble retrieving the value?
i tried adding the varible to the function call like so
store_filterForm($category);
but it said something about argument 1 missing so im assuming i need two arguments but im not sure what :(
any ideas please
Thanks
i have a form which i have set as a function as i require calling this form in several sections of my code, the problem im having is that one my main page i have a varible which is being used in my form function but it doesnt recognise its value?
here is my function
<?php
function store_filterForm(){
?>
<div class="form">
<form id="filter" action="stores.php" method="get">
<fieldset>
<div>
<div class="label">
<label for="cat_select">Category</label></div>
<select id="cat_select" name="cds">
<?php
print $category;
$options=array('entertainment','computing','electronics','clothing','health','misc');
foreach($options as $option) {
if($category==$option) {
echo "<option value=\"{$option}\" selected=\"selected\">{$option}</option>";
}
else {
echo "<option value=\"{$option}\">{$option}</option>";
}
}
?>
</select>
</div>
<div>
<div class="label">
<label for="filter_by">Filter By</label></div>
<select id="filter_by" name="filter_list">
<?php
$options=array('None','Name','Rating');
foreach($options as $option) {
if($b==$option) {
echo "<option value=\"{$option}\" selected=\"selected\">{$option}</option>";
}
else {
echo "<option value=\"{$option}\">{$option}</option>";
}
}
?>
</select>
</div>
<input type="submit" name="submit" id="submit" value="Filter" />
</fieldset>
</form>
</div>
<?php
}
?>
and the varible im trying to use is $category which i have tried printing out but nothing printed proving that the function is having trouble retrieving the value?
i tried adding the varible to the function call like so
store_filterForm($category);
but it said something about argument 1 missing so im assuming i need two arguments but im not sure what :(
any ideas please
Thanks