Jump to content

Query


teknospr

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.