Jump to content

For Loops


supanoob

Recommended Posts

ok so i have this code for my [b]for[/b] loop. now what i need to do is insert another 2 queries, one to select 2 things from the per who made the post, this will be done using the Poster_id, and another to select something from another table using Legion_id found within the query selected from the player.

[code]$query3="select poster_name, poster_id, board, post_date, reply_to, reply_body, reply_subject, post_id from forum where reply_to='$post'";
$result3=mysql_query($query3);
if (!$result3)
{
die (mysql_error());
}

$num_rows=mysql_num_rows($result3);
for ($i=0;$i<$num_rows;$i++)
{
$row=mysql_fetch_array($result3);
$poster_name2=($row['poster_name']);
$poster_id2=($row['poster_id']);
$board2=($row['board']);
$post_date2=($row['post_date']);
$reply_to=($row['reply_to']);
$reply_body=($row['reply_body']);
$reply_subject=($row['reply_subject']);
$post_id2=($row['post_id']);[/code]

so i have the 2 queries:

[b]Query 1 using the poster_id[/b]
[code]$query4="select name, postcount, legion_id from players where playerid='$poster_id2'";
$result4=mysql_query($query4);
if (!$result4)
{
die (mysql_error());
}

$num_rows=mysql_num_rows($result4);
$row=mysql_fetch_array($result4);
$name3=($row['name']);
$postcount3=($row['postcount']);
$legion_id3=($row['legion_id']);[/code]

[b]Query 2 using the legion_id[/b]
[code]$query5="select legion_name from legions where legion_id='$legion_id3'";
$result5=mysql_query($query5);
if (!$result5)
{
die (mysql_error());
}

$num_rows=mysql_num_rows($result5);
$row=mysql_fetch_array($result5);
$legion_name2=($row['legion_name']);[/code]

all i need to know is where to place them in the loop. since when i put them in it only echos one result then kills the loop.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.