where are all my records??
these few lines of code below print records that are in the database. for eg. i have 10 records and it will print 10 records.
<?php
for($i=0;$i<mysql_num_rows($result);$i++) {
list($taker_name, $taker_email, $show_record, $no_total, $no_correct, $time_taken, $time) = mysql_fetch_row($result);
$percentage = round($no_correct/$no_total*10000) / 100;
$row_color = ($i % 2) ? $table_color_1 : $table_color_2;
print \"<tr>\n\";
if ($show_record) $taker_name = \"<a href=\\"mailto:$taker_email\\">$taker_name</a>\";
print \" <td align=center bgcolor=$row_color><font face=\\"$font_face\\" color=\\"$font_color\\" size=2>$taker_name</font></td>\n\";
print \" <td align=center bgcolor=$row_color><font face=\\"$font_face\\" color=\\"$font_color\\" size=2>$no_total</font></td>\n\";
print \"</tr>\n\";
}
?>
after i've change the code into these:
<?php
for($i=0;$i<mysql_num_rows($result);$i++)
{
list($taker_name, $taker_email, $show_record, $no_total, $no_correct, $time_taken, $time) = mysql_fetch_row($result);
$percentage = round($no_correct/$no_total*10000) / 100;
$row_color = ($i % 2) ? $table_color_1 : $table_color_2;
print \"<tr>\n\";
if ($show_record)
{
$database = 'forum';
mysql_select_db($database);
$result = mysql_query(\"SELECT userid FROM user WHERE username='$name'\");
if ($result)
{
list ($userid, $username) = mysql_fetch_row($result);
}
$taker_name = \"<a href=\\"http://www.certifyexpress.com/forum/member.php?s=&action=getinfo&userid=$userid\\">$taker_name</a>\";
}
print \" <td align=center bgcolor=$row_color><font face=\\"$font_face\\" color=\\"$font_color\\" size=2>$taker_name</font></td>\n\";
print \" <td align=center bgcolor=$row_color><font face=\\"$font_face\\" color=\\"$font_color\\" size=2>$no_total</font></td>\n\";
print \"</tr>\n\";
}
?>
after i've changed the code, it only print one record..wat is the problem??
pls advice..
Mark Hensler posted this at 06:29 — 19th December 2001.
He has: 4,048 posts
Joined: Aug 2000
It's messy to nest queries when you can use a JOIN clause.
Can you post the query for the first loop?
joyce posted this at 07:44 — 19th December 2001.
They have: 164 posts
Joined: Nov 2001
seems that my '$result' overwriting each other..that is why i only got one line record displayed..
Mark Hensler posted this at 07:49 — 19th December 2001.
He has: 4,048 posts
Joined: Aug 2000
oh ya... 8]
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.