I want to echo the results I want, how can I filter them further?
example, search x100 y100
, currently get hundreds of results. I need to filter these results further so I only get those thats are marked hostile, pending or friendly
I have the following html form
<form action="xysearch.php" method="post">
<label>X Coord
<input type="text" name="x" />
</label>
<label>Y Coord
<input type="text" name="y" />
</label>
<select name="term">
<option value="Hostile">Hostile</option>
<option value="Pending">Pending</option>
<option value="Friendly">Friendly</option>
</select>
<input type="submit" value="Search" />
</form>
what I need to add to the search query is a way to filter those results so only the option selected in the diplomacy dropdown are shown
My query thus far which is not working - I can get ALL the results, but not just the filtered ones.
<?php
$x = $_POST['x'];
$y = $_POST['y'];
$term = $_POST['term'];
mysql_connect ("localhost","host","pass") or die (mysql_error());
mysql_select_db ("d_base");
$res = mysql_query("SELECT * FROM my_table WHERE (x BETWEEN $x -75 AND $x +75) AND (y BETWEEN $y -75 AND $y +75) ");
$res2 = mysql_query("SELECT dip FROM my_table WHERE dip IN '%$term%' ORDER BY '%$term%' DESC ");
echo "<table border='1' align='center' cellpadding='5'>";
echo "<tr> <th>City Name</th> <th>X</th> <th>Y</th> <th>Diplomacy</th> </tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $res, $res2 )) {
// echo out the contents of each row into a table
echo '<td>' . $row['city'] . '</td>';
echo '<td>' . $row['x'] . '</td>';
echo '<td>' . $row['y'] . '</td>';
echo '<td>' . $row['dip'] . '</td>';
echo "</tr>";
// close table>
echo "</table>";
}
?>
I'm not too sure where i am going wrong as i can actually get results to echo, is just the filtering thats the issue.