sopranolv Posted February 10, 2015 Share Posted February 10, 2015 How to get all users with same city <?php function quote_smart($value) { $value = htmlspecialchars($value); if (get_magic_quotes_gpc()) { $value = stripslashes($value); } $value = "'" . mysql_real_escape_string($value) . "'"; return $value; } $pilseta = quote_smart($_GET['city']); $select_u = mysql_query("SELECT * FROM `users` WHERE `city` = $pilseta"); while($u = mysql_fetch_array($select_u)){ echo $u['username'];?> <? } ?> this script works x.php?city=new-york or other city. but i need to show users from the same city from which I am in my profile have city jelgava and I want to make this script show another users with same city get logged in users id by cookies Quote Link to comment https://forums.phpfreaks.com/topic/294502-get-users-with-one-city/ Share on other sites More sharing options...
Barand Posted February 10, 2015 Share Posted February 10, 2015 String values need to be inside single quotes in a query $select_u = mysql_query("SELECT * FROM `users` WHERE `city` = '$pilseta' "); Quote Link to comment https://forums.phpfreaks.com/topic/294502-get-users-with-one-city/#findComment-1505345 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.