php - only grabbing first character from string array -
so have query supposed generate sentance saying "conversation between x , x' right now, getting print first 2 digits of users userids. alter query grab usernames, starting userid's now. array in strings, think same issue happening if grabbing usernames.
also, know it's deprecated... plan on switching sqli shortly. should have no effect on this. query works fine, think it's grabbing array wrong.
$sql1 = "select distinct(userid) userid message_recips messageid=$_get[id]"; echo $sql1; $result1=mysql_query($sql1); var_dump($result1); $results2=mysql_fetch_array($result1); var_dump($results2); $uids= array(); foreach ($results2 $result) { $uids[] = (int)$result['userid']; } $last = array_pop($uids); print '<p>conversation between '; print implode(', ', $uids) . ' , ' . $last; echo '.</p>';
here printing array:
conversation between 2 , 2.
when array looks :
array (size=2) 0 => string '274' (length=3) userid' => string '274' (length=3)
sincere help! have looked around tried bunch of things similar issues cannot find 1 mine.
//$results2=mysql_fetch_array($result1); $uids = array(); while ($row = mysql_fetch_assoc($result1)) { $uids[] = $row['userid']; } $last = array_pop($uids);
php sql arrays
No comments:
Post a Comment