Note that there are some explanatory texts on larger screens.

plurals
  1. POfiltering my search further
    primarykey
    data
    text
    <p>I want to echo the results I want, how can I filter them further?</p> <p><strong>example</strong>, <code>search x100 y100</code>, currently get hundreds of results. I need to filter these results further so I only get those thats are marked hostile, pending or friendly </p> <p>I have the following html form</p> <pre><code>&lt;form action="xysearch.php" method="post"&gt; &lt;label&gt;X Coord &lt;input type="text" name="x" /&gt; &lt;/label&gt; &lt;label&gt;Y Coord &lt;input type="text" name="y" /&gt; &lt;/label&gt; &lt;select name="term"&gt; &lt;option value="Hostile"&gt;Hostile&lt;/option&gt; &lt;option value="Pending"&gt;Pending&lt;/option&gt; &lt;option value="Friendly"&gt;Friendly&lt;/option&gt; &lt;/select&gt; &lt;input type="submit" value="Search" /&gt; &lt;/form&gt; </code></pre> <p>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</p> <p>My query thus far which is not working - I can get ALL the results, but not just the filtered ones.</p> <pre><code>&lt;?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 "&lt;table border='1' align='center' cellpadding='5'&gt;"; echo "&lt;tr&gt; &lt;th&gt;City Name&lt;/th&gt; &lt;th&gt;X&lt;/th&gt; &lt;th&gt;Y&lt;/th&gt; &lt;th&gt;Diplomacy&lt;/th&gt; &lt;/tr&gt;"; // 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 '&lt;td&gt;' . $row['city'] . '&lt;/td&gt;'; echo '&lt;td&gt;' . $row['x'] . '&lt;/td&gt;'; echo '&lt;td&gt;' . $row['y'] . '&lt;/td&gt;'; echo '&lt;td&gt;' . $row['dip'] . '&lt;/td&gt;'; echo "&lt;/tr&gt;"; // close table&gt; echo "&lt;/table&gt;"; } ?&gt; </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload