Web Hosting Talk







View Full Version : Quick PHP problem


NickMahon
09-21-2002, 10:40 PM
<table width="100%" cellpadding="4" cellspacing="0" border="0">
<?php
$link_id = mysql_connect( [ None of your business!! ] )
mysql_select_db("nmahon_nmahonsanctuary", $link_id);
$i = 1;
$result = mysql_query("SELECT topic_time, topic_id, topic_title FROM `phpbb_topics` ORDER BY `topic_time` DESC LIMIT 10");
$result2 = mysql_fetch_row($result);
while($i < 10) {
if($i%2!=0){
$class = "row1";
} else {
$class = "row2";
}
?>
<tr>
<td class="<?=$class?>">
<a href="viewtopic.php?t=<?=$result2[1]?>"><?=$result2[2]?></a>
</td>
</tr>
<?php
}
?>
</table>


Hello,

This code is supposed to grab the 5 latest topics from phpBB, arrange them in a table, and link to them.

It seems to be an infinate loop: http://www.vereor.com/sanctuary

Thanks,
Nick

ffeingol
09-21-2002, 10:46 PM
Nick,

You're not incrementing $i within the while loop ;).

Frank

NickMahon
09-21-2002, 10:47 PM
Here's another:

Now it returns 10 of the same topic.

NickMahon
09-21-2002, 10:50 PM
Figured it out, with Frank's help.

Thanks :)

Acronym BOY
09-21-2002, 11:47 PM
Whoa.

I clicked the link to see how it was looking and thought it looked really sweet, but wasnt sure if it was custom or a template. Than I looked at the domain and than looked at the poster here.

You do nice work Nick! :)

NickMahon
09-21-2002, 11:49 PM
Thanks :) Now if only I could solve the PHP problem in my other thread :bawling: