I am using mysql with a table with 2 collums, PK_ID and User_ID.
The PK_ID is the ID of the current user and User_ID is a list of IDs of their contacts.
I.e
PK_ID | User_ID
96 | 23
96 | 21
96 | 12
I am using the following code to count how many users they have on their list, then storing it into an array so I can print each user_id to the screen.
The array I am using doesn't seem to store more than 1 result in it when it should be storing 3.
Any ideas why?
$countUsers = mysql_query ("SELECT count(*) from UsersContactlist WHERE PK_ID='$PK_ID'");
$count = mysql_result($countUsers, 0);
//get all users PK_IDs on contact list
//$gatherUsers = mysql_query ("SELECT User_ID from UsersContactlist WHERE PK_ID='$PK_ID'");
$gatherUsers = mysql_query ("SELECT User_ID from UsersContactlist WHERE PK_ID='$PK_ID'");
if (mysql_num_rows($gatherUsers) > 0)
{
$users=mysql_fetch_array($gatherUsers);
//loop to get User_IDs
for ($i=0; $i<$count; $i++)
{
echo $users[$i];
echo "<br>";
//$users = mysql_result($gatherUsers, $i);
}
}