So I have this query that is supposed to generate a sentance saying "conversation between x and x' but right now, I am only getting it to print the first two digits of those users userids. Ultimately I will change the query to grab their usernames, but I am just starting with userid's for now. As the array is in strings, I think the same issue would be happening if I was grabbing the usernames.
Also, I know it's deprecated... I plan on switching to sqli shortly. Should have no effect on this. The query works fine, i think it's just grabbing from the array wrong.
$sql1 = "SELECT distinct(userid) as userid FROM message_recips WHERE messageid=$_GET[id]";
echo $sql1;
$result1=mysql_query($sql1);
var_dump($result1);
$results2=mysql_fetch_array($result1);
var_dump($results2);
$uids= array();
foreach ($results2 as $result) {
$uids[] = (int)$result['userid'];
}
$last = array_pop($uids);
print '<p>Conversation between ';
print implode(', ', $uids) . ' and ' . $last;
echo '.</p>';
Here is what it is printing from the array:
Conversation between 2 and 2.
when the array looks like :
array (size=2)
0 => string '274' (length=3)
userid' => string '274' (length=3)
Sincere thanks for any help! I have looked around tried a bunch of things that from similar issues but cannot find one for mine.