CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 While loop to populate grid

Print topic Send  topic

Author Message
Nizzan
Posted: 06/07/2004, 10:37 AM

In normal php I'll do this;

$sql = 'select friend_id from friends where user_id = 1';
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
$sql2 = 'select * from items where friend_id = ' . $row['friend_id'];
$result2 = mysql_query($sql);
while($row = mysql_fetch_array($result)){
DO GRID ROWS HERE
}
}

Only friends of user id 1 items will be shown. These friends will have
different id.

Thanks,

Nizzan
Posted: 06/07/2004, 10:40 AM

There are missing text on the top. Sorry.

What I really need is a way to loop mysql query a few time to produce the
desired output.


"Nizzan" <nizzan@salsabil.biz> wrote in message
news:ca294l$49q$1@news.codecharge.com...
> In normal php I'll do this;
>
> $sql = 'select friend_id from friends where user_id = 1';
> $result = mysql_query($sql);
> while($row = mysql_fetch_array($result)){
> $sql2 = 'select * from items where friend_id = ' . $row['friend_id'];
> $result2 = mysql_query($sql);
> while($row = mysql_fetch_array($result)){
> DO GRID ROWS HERE
> }
> }
>
> Only friends of user id 1 items will be shown. These friends will have
> different id.
>
> Thanks,
>
>

Last Hero
Posted: 06/08/2004, 6:42 AM

Hm...
Please read some articles about relational databases.
You does not need second WHILE.
Read about SELECT with JOIN clause.

CCS can make datasource on few joined tables.

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.