Jump to content

Archived

This topic is now archived and is closed to further replies.

MrLarkins.com

is this possible?

Recommended Posts

while($main = mysql_fetch_array($main)){
$id = $main['id'];
$name = $main['name'];
$email = $main['email'];

$icq = mysql_query("SELECT icq_number FROM ibf_member_extra WHERE id = $id");
$icq_number = $icq['icq_number'];

//then do html to display results
}

my question is about the mysql query within the while(), is this possible, or is there a better way?

Share this post


Link to post
Share on other sites
Whats the query used before the while loop. You shoud use a join instead if the two tables you are querying relate.

If you use a join you dont need to do another (uneeded) query in the while loop.

Share this post


Link to post
Share on other sites
sorry, here is the full part

$main = mysql_query("SELECT id, name, email FROM ibf_members WHERE mgroup=4 ORDER BY id");
while($main = mysql_fetch_array($main)){ //while you have records available from the SELECT query
$id = $main['id'];
$name = $main['name'];
$email = $main['email'];

$icq = mysql_query("SELECT icq_number FROM ibf_member_extra WHERE id = $id");
$icq_number = $icq['icq_number'];

//then do html to display results
}

Share this post


Link to post
Share on other sites
Prehaps use this as the query for $main:
[code]SELECT m.id, m.name, m.email, me.icq_number
FROM ibf_members as m, ibf_members_extra as me WHERE m.mgroup=4, m.id = me.id ORDER BY m.id[/code]
It is untested however it should work.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.