sp@rky13 Posted August 13, 2009 Share Posted August 13, 2009 Ok so I've been messing with the following code but don't know what i've done wrong. The error is definitely here. $result4 = mysql_query("SELECT * FROM villages_en28 WHERE player = '".$id2"' AND x BETWEEN 400 AND 450 AND y BETWEEN 400 and 450"); What it should do is take all the values of id2 and look them up in the table village and then only keep the ones that have an x value between 400 and 450 as well as a y value between 400 and 450. I would then echo those results like this: while($row4 = mysql_fetch_array($result4)) { echo $row4['x']."|".$row4['y']."</br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/170068-what-did-i-do-wrong-in-this/ Share on other sites More sharing options...
aschk Posted August 13, 2009 Share Posted August 13, 2009 Are you getting an error or just no results? If the latter (no results) then I suggest you look at what data you are expecting. Run the following with a static "id" value directly in MySQL to see what results you are getting. SELECT * FROM villages_en28 WHERE player = '< PLACE ID HERE >' AND x BETWEEN 400 AND 450 AND y BETWEEN 400 and 450 If you get no results examine why the data doesn't match up. I suspect because there is no player with x and y between those values. Also consider bracketing your SQL for better clarity, e.g. ... AND (x BETWEEN 400 AND 500) AND ... Quote Link to comment https://forums.phpfreaks.com/topic/170068-what-did-i-do-wrong-in-this/#findComment-897226 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.