All pastes #94366 Raw Edit

Anonymous

public text v1 · immutable
#94366 ·published 2006-07-21 06:23 UTC
rendered paste body
<?php

include("database.php");

// selects all the rows from the "categories" table, then orders them by id, ascending. 
$result = mysql_query("select * from categories order by id asc") or die(mysql_error()); 

// a while loop to repeat code until all our rows have been echo'd out.. 
while($r = mysql_fetch_array($result)) 
{ 
	// redefine our category row variables. 
	$category_id = $r['id']; 
	$category_title = $r['title']; 
	$category_description = $r['description']; 

	echo '
	<table cellpadding="5" cellspacing="1" border="0" style="width:90%;border:1px solid #000;"> 
	<tr><td colspan="4" style="background-color:#eee;">
	';

	echo $category_title;
	echo '<BR>';
	echo $category_description;

	echo '</td></tr>';

	// selects our forums if the "cid" is the same as our $category_id. 
	$result2 = mysql_query("select * from forums where cid = '$category_id'");
}
      
// the while loop to echo out our corresponding forums 
while($r2 = mysql_fetch_array($result2)) 
{ 
	// redefine our forum row variables. 
	$forum_id = $r2['id']; 
        $forum_title = $r2['title']; 
        $forum_description = $r2['description']; 
        $forum_last_post_title = $r2['last_post_title']; 
        $forum_last_post_username = $r2['last_post_username']; 
        $forum_topics = $r2['topics']; 
        $forum_replies = $r2['replies']; 

	echo '<tr><td style="width:50%;background-color:#fafafa;"> ';

	echo '<a href="viewforum.php?f=' . $forum_id . '">' . $forum_title . '></a><br>';
	echo $forum_description;

	echo '</td><td style="width:30%;background-color:#fafafa;">';

	echo $forum_last_post_title;
	echo '<BR>';
	echo $forum_last_post_username;

	echo '</td><td style="width:10%;background-color:#fafafa;">';

	echo $forum_topics;

	echo '</td><td style="width:10%;background-color:#fafafa;">';

	echo $forum_replies;

	echo '</td></tr>';

} //end while loop

?>