0

Here is exactly what I would like to do (step by step in the order it makes sense to me)

  1. SELECT FROM table
  2. WHERE x is within +/- 6 from variable $x
  3. AND WHERE y is within +/- 6 from variable $y
  4. And hopefully have it all returned in a neatly organized array..

Is this possible? Not really looking to get it handed to me, more looking for a starting point to search.

3 Answers 3

2

BETWEEN is your answer.

SELECT * FROM table WHERE x BETWEEN $x-6 AND $x+6 AND y BETWEEN $y-6 AND $y+6

Put in a mysqli_query (or use PDO) and fetch the results.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much, this has helped out a ton!
0

you can only one where clause in one select statement

but you can you multiple comparator like

select * from table where (col1=10 and column2>25)  or col3=10

for your above query it

select * from table where (x>-6 and x<6) and  (x>-6 and x<6)

Comments

0
SELECT * FROM table
WHERE x >= $x - 6 AND x <= $x + 6
AND y >= $y - 6 AND y <= $y + 6

Then use PHP's functions to fetch_array on the query

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.