teknospr Posted July 27, 2011 Share Posted July 27, 2011 Good day: Im trying to do a query where I select all users in a table except myself by using the column id as identifier. My id number is passed as variable and I have used the GET command to convert it in a variable for the query. So i need to do a query of all other users. Here is the code to select all users: $query="SELECT id, name, initial, last, secondlast, phone, last4, username FROM users WHERE active='1' AND id <> $usid ORDER BY last, secondlast, name, initial"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); Thanks in advance for the help. Quote Link to comment https://forums.phpfreaks.com/topic/242957-query/ Share on other sites More sharing options...
Nodral Posted July 27, 2011 Share Posted July 27, 2011 So what is your question? Quote Link to comment https://forums.phpfreaks.com/topic/242957-query/#findComment-1247912 Share on other sites More sharing options...
Muddy_Funster Posted July 27, 2011 Share Posted July 27, 2011 take out "active='1' AND" p.s. why is 'active' storing numerical data in string format? Quote Link to comment https://forums.phpfreaks.com/topic/242957-query/#findComment-1247914 Share on other sites More sharing options...
Maq Posted July 27, 2011 Share Posted July 27, 2011 As suggested above, we need more information. You haven't actually asked a question and we don't know what the problem is you're having. Quote Link to comment https://forums.phpfreaks.com/topic/242957-query/#findComment-1247922 Share on other sites More sharing options...
sunfighter Posted July 27, 2011 Share Posted July 27, 2011 As said , remove the quotes around the number 1. And as a stab in the dark: $query="SELECT id, name, initial, last, secondlast, phone, last4, username FROM users WHERE active=1 AND id <> $usid ORDER BY last, secondlast, name, initial"; $result = mysql_query($query); $colCount = mysql_num_fields($result); while($row = mysql_fetch_row($result)) { for($colNumber = 0; $colNumber < $colCount; $colNumber++){echo $row[$colNumber],' -- ';} echo '<br>'; } Quote Link to comment https://forums.phpfreaks.com/topic/242957-query/#findComment-1248149 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.