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. 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? 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? 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. 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>'; } Link to comment https://forums.phpfreaks.com/topic/242957-query/#findComment-1248149 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.