garrensilverwing
New Member
- Messages
- 148
- Reaction score
- 0
- Points
- 0
there is probably an easier way to do this but what I want to do is, when people search for multiple things it to display results that match everything that they put in this is the code I have so far, there is a lack of tutorials online so everything is just me trying to figure out for the whole day please if you know an easier way or if you can help me with this code it will be greatly appreciated. I did my best to keep the brackets lined up so please dont yell at me if something is misaligned, its all coded by hand and I don't have much experience...
here are the error messages I get when I try a search:
Warning: Wrong parameter count for array_count_values() in /home/frostbit/public_html/games/gameshome/search/search1.php on line 120
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/frostbit/public_html/games/gameshome/search/search1.php on line 117
thanks in advance
here are the error messages I get when I try a search:
Warning: Wrong parameter count for array_count_values() in /home/frostbit/public_html/games/gameshome/search/search1.php on line 120
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/frostbit/public_html/games/gameshome/search/search1.php on line 117
Code:
<?php
require ('../../../../dbgames_connect.php');
$classmin[G]="600";
$classmin[F]="800";
$classmin[E]="1000";
$classmin[D]="1200";
$classmin[C]="1400";
$classmin[B]="1600";
$classmin[A]="1800";
$classmin[X]="2000";
$classmin[M]="2200";
$classmin[Z]="600";
$classmax[G]="799";
$classmax[F]="999";
$classmax[E]="1199";
$classmax[D]="1399";
$classmax[C]="1599";
$classmax[B]="1799";
$classmax[A]="1999";
$classmax[X]="2199";
$classmax[M]="3000";
$classmax[Z]="3000";
if (!$_POST['search'])
{
?>
<html>
<form method="post" style="text-align: center;" action="search1.php">
Search Games, for help and tips <a href="help.htm" target="_blank">click here</a>.<br>
White:<br>
First Name:
<input name="wFirst" type="text" tabindex="1"> Last Name:<input name="wLast" type="text" tabindex="2"> <br>
Rating:
<input name="wRating" type="text" tabindex="3" style="height: 22px" size="4">
OR:
<select name="wClass" tabindex="4" style="height: 22px">
<option value="Z" selected="">Select Class</option>
<option>G</option>
<option>F</option>
<option>E</option>
<option>D</option>
<option>C</option>
<option>B</option>
<option>A</option>
<option value="X">Expert</option>
<option value="M">Master+</option>
</select><br>
<br>
Black:<br>
First Name:
<input name="bFirst" type="text" tabindex="5"> Last Name:
<input name="bLast" type="text" tabindex="6">
<br>
Rating:
<input name="bRating" type="text" tabindex="7" size="4" style="width: 32px"> OR:
<select name="bClass" tabindex="8">
<option value="Z" selected="">Select Class</option>
<option>G</option>
<option>F</option>
<option>E</option>
<option>D</option>
<option>C</option>
<option>B</option>
<option>A</option>
<option value="X">Expert</option>
<option value="M">Master+</option>
</select><br>
<br>
Game Info:<br>
Eco:
<input name="eco" type="text" tabindex="9" size="3"> (<a target="_blank" href="ecocodes.htm">help</a>)<br>
Year:
<input name="year" type="text" tabindex="10" size="4">
<select name="result" tabindex="11">
<option>Select Result</option>
<option>Win (not a draw)</option>
<option>1-0</option>
<option>0-1</option>
<option>1/2-1/2</option>
</select>
<br>
<input name="search" type="submit" value="Search" tabindex="12"></form>
</html>
<?php
}
else {
$wValue=$_POST['wClass'];
$bValue=$_POST['bClass'];
$wRatingmin=$classmin[$wValue];
$wRatingmax=$classmax[$wValue];
$bRatingmin=$classmin[$bValue];
$bRatingmax=$classmax[$bValue];
if ($_POST['wFirst'])
{$arr[wFirst]=strtolower($_POST['wFirst']);}
if ($_POST['wLast'])
{$arr[wLast]=strtolower($_POST['wLast']);}
if ($_POST['bFirst'])
{$arr[bFirst]=strtolower($_POST['bFirst']);}
if ($_POST['bLast'])
{$arr[bLast]=strtolower($_POST['bLast']);}
if ($_POST['eco'])
{$arr[eco]=$_POST['eco'];}
if ($_POST['year'])
{$arr[year]=$_POST['year'];}
if ($_POST['wRating'])
{$arr[wRating]=$_POST['wRating'];}
if ($_POST['bRating'])
{$arr[bRating]=$_POST['bRating'];}
$counter=1;
foreach($arr as $key => $value)
{
$query = mysql_query("SELECT * FROM games
WHERE $key LIKE '$value'") or die(mysql_error());
$queries[$counter]=$query;
$counter=$counter+1;
}
$counter=1;
while($row = mysql_fetch_array($queries[$counter]))
{
$searches=count($arr);
$valuecount=array_count_values($queries,$queries[$counter]);
if ($valuecount==$searches)
{
echo "$counter. <a href=\"".$row['link']."\" target=\"RightSide\">".$row['wLast']." (".$row['wRating'].") - ".$row['bLast']." (".$row['bRating'].")</a><br />";
}
$counter=$counter+1;
}
if (count($queries)=="0")
{
echo "Sorry, your search found no results.";
}
}
?>
thanks in advance
Last edited: