-
can't get array values sent from form into one variable
I have an online search with a drop list that allows multiple selections, then sends them as an array to a script on a different page to be used as the database search criteria. the problem is that I can't get it to read the actual selections, instead it just selects everything regardless of the array values. When I don't send it as an array it repeats the variable for each value and the recieving page only recognizes the last value sent. Is this even a good way or is there something better besides an array?
the code looks like this:
///////form code///////
<form action="recieve.php" method="get">
<input type="hidden" name="src" value="catagorySearchResults">
<select MULTIPLE name="Catagory[]" size="3">
<option>All</option>
<option>Accounting</option>
<option>Acupuncture</option>
<option>Advertising</option>
<option>Air Filters</option>
<option>Art</option>
//////etc.///////
</select>
<br>
<input name="submit" type="submit" value="Search">
</form>
////////recieve code/////////
case "catagorySearchResults":
$x = 0;
$Catagory = ($HTTP_GET_VARS['Catagory']);
$result = mysql_query("SELECT contNum, BusNam FROM ClientInfo WHERE Catagory LIKE '%".$Catagory."%' ORDER BY 'BusNam' 'a TO z'",$link) or die("error with the sql statement");
while ($myrow = mysql_fetch_row($result)) {
echo $myrow[1];
echo "<a href=AdminEdit.php?src=displayClientdet&contNum={$ myrow[0]}><strong>View and Edit</strong></a>";
$x = ($x+1);
}
echo "<br><center>";
echo "TOTAL NUMBER OF ENTRIES = ";
echo $x;
break;
-
Give each option a value:
Code:
<option value="1">Accounting</option>
<option value="2">Acupuncture</option>
...
...and what you'll get is an array of the selected values.
-
Not Sure?
I'm not sure I understand. I tried that and it still Says "Array" when I echo the variable $Catagory, and seems to just replace the actual catagory name with the number. What I need to do is have it use the words Accounting Acupuncture Advertising etc. to query the data base. I am fairly new to php so I'm may be miss explaing this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|