0

i am actually working for showing online for loged in user. This is my code:

    $qt="select userid from plus_login where tm > '$tm' and status='ON'";
    $result = mysql_query($qt);
    while($row=mysql_fetch_array($result))
    {
        $uid = $row['userid'];
        $qt1="select first_name, last_name from signup where user_id='$uid'";
    $result1 = mysql_query($qt1);
    while($rows=mysql_fetch_array($result1))
    {
            $_SESSION['name']=$rows[0]." ".$rows[1];
            echo $_SESSION['name']."<br>";
    }

    }

This above code is working but i want all $_SESSION['name'] which is in loop and displaying different values fetched from database to be shown in another pages. When i echo $_SESSION['name'] in another, it shows only one value. I think i need to store all value that is fetched from database in array form. How can i do it. Please help me. Thanks in advance.

2
Contributors
4
Replies
21
Views
3 Years
Discussion Span
Last Post by diafol
0

try

$_SESSION['name'][] =$rows[0]." ".$rows[1];

However, it's difficult to see why there would be more than one user with a specific id.

0

no actually $rows[0] and $rows[1] are first name and last respectively.

0

No you don't understand me:

You use 'while' loops in both cases, I fail to see why each resultset should contain more than one record.

Edited by diafol

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.