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.

why no any reply.

commented: because question is not clear.. +0
Member Avatar for diafol

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.

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

Member Avatar for diafol

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.