how to return multiple array items using json/jquery

Posted by Scarface on Stack Overflow See other posts from Stack Overflow or by Scarface
Published on 2010-04-28T15:49:11Z Indexed on 2010/04/28 15:53 UTC
Read the original article Hit count: 472

Filed under:
|

Hey guys, quick question, I have a query that will usually return multiple results from a database, while I know how to return one result, I am not sure how to return multiple in jquery. I just want to take each of the returned results and run them through my prepare function. I have been trying to use 'for' to handle the array of data but I don't think it can work since I am returning different array values. If anyone has any suggestions, I would really appreciate it.

JQUERY RETRIEVAL

 for(i=0; i < json.rows; i++) {

                $('#users_online').append(online_users(json[i]));
                $('#online_list-' + count2).fadeIn(1500);
              } 

PHP PROCESSING

$qryuserscount1="SELECT active_users.username,COUNT(scrusersonline.id) AS rows FROM scrusersonline LEFT JOIN active_users ON scrusersonline.id=active_users.id WHERE topic_id='$topic_id'";
$userscount1=mysql_query($qryuserscount1);
while ($row = mysql_fetch_array($userscount1)) {
$onlineuser= $row['username'];
$rows=$row['rows'];
if ($username==$onlineuser){
    $str2=  "<a href=\"statistics.php?user=$onlineuser\"><div class=\"me\">$onlineuser</div></a>";
    }
else {
$str2= "<b><a href=\"statistics.php?user=$onlineuser\"><div class=\"others\">$onlineuser</div></a></b>";
}
$data['rows']=$rows;
$data['entry']=$str1.$str2;
}

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about php