I have two while loops populating associative arrays -- I can run one at a time (ie commenting the other out) however, when I run both at the same time I receive a server error. Despite the queries not querying the same set of data I've still tried adding a pointer reset with no luck. Here are the two loops:
$thecurrent = array();
$getusers = "SELECT score, uid, like_id FROM wetique_scores GROUP BY like_id;";
$gotusers = mysql_query($getusers,$con);
while ($row = mysql_fetch_array($gotusers))
{
$score = $row['score'];
$userid = $row['uid'];
$likeid = $row['like_id'];
$comboid = $userid.$likeid;
$thecurrent[$comboid] = $score;
}
// 2. calculate new score from db and create array $new
$new = array();
$getusers2 = "SELECT like_id, sum(friend_rating), uid from likes l, friendships f WHERE l.friend_id = f.friend_id GROUP BY l.like_id;";
$gotusers2 = mysql_query($getusers2,$con);
while ($rowb = mysql_fetch_array($gotusers2))
{
$scoreb = $rowb['sum(friend_rating)'];
$useridb = $rowb['uid'];
$likeidb = $rowb['like_id'];
$comboidb = $useridb.$likeidb;
$new[$comboidb] = $scoreb;
}
from l,
in second query. Is this a typo or table name isl
? – Gaurav May 4 '11 at 7:50sum(friend_rating)
such assum(friend_rating) AS sum
, so you can do$rowb['sum']
. – Rocket Hazmat May 4 '11 at 13:18