Hi could some please help me... I am creating a pagination system for a online forum and the pagination works fine for when i output the topics and the pages also work fine.
However when i try to create the pagination system for the various replies within a particular subject heading. The system does not work. The topic_id which is the id for a particular topic is passed in through the URL when the user clicks on the hyperlink of the subject.
The pages seem to echo fine but when i go to another page apart from the first one nothing is displayed.
Could someone please have a look at the following code and see where am going wrong... Any help is truely appreciated.....
PHP Code:
$data = $_GET['id'];
$update_views = mysql_query("UPDATE forum_topic SET topic_views = topic_views + 1 WHERE topic_id = $data");
$test = mysql_query("SELECT * FROM forum_posts WHERE topic_id = '$data' ORDER BY post_time ASC");
$num_rows = mysql_num_rows($test);
setcookie("tester", "$data");
$salma .= $data;
$SQL = mysql_query("SELECT COUNT(*) AS Total FROM forum_posts WHERE topic_id = '$salma' ORDER BY post_time ASC");
$SQL_Result_Array = mysql_fetch_array($SQL);
$Total = $SQL_Result_Array['Total'];
$Result_Set = 0;
$per_page = 3;
if (empty($_GET['Result_Set']))
{
$Result_Set = 0;
$SQL2 = mysql_query("SELECT * FROM forum_posts WHERE topic_id = '$salma' LIMIT $Result_Set, $per_page");
echo "<br>";
}
else {
$Result_Set = $_GET['Result_Set'];
$SQL2 = mysql_query("SELECT * FROM forum_posts WHERE topic_id = '$salma' LIMIT $Result_Set, $per_page ");
}
?>
<tr>
<table width="65%" border="0" cellspacing="2" cellpadding="5" bgcolor="white" div align = "center">
<td width="25%" bgcolor="#990033"><font size="3" face="<?php echo $default_font; ?>" color="#FFFFFF"><b>Posted</b></font></td>
<td width="75%" bgcolor="#990033"><font size="3" face="<?php echo $default_font; ?>" color="#FFFFFF"><b><?php echo subject ?></b></font></td>
</tr>
<br><br>
<?php
for ($a = 0; $a <= $Total; $a++) {
$SQL_Array = mysql_fetch_array($SQL2);
$topic_title = $SQL_Array['topic_title'];
$post_text = $SQL_Array['post_text'];?>
<td> <?php echo $topic_title; ?>
<td> <?php echo $post_text;
echo "<tr>"; ?>
<?php
}
if ($Total > 0) {
if ($Result_Set < $Total && $Result_Set > 0) {
$Res1 = $Result_Set - $per_page;
echo "<A HREF=\"$self?Result_Set=$Res1\">Prev</A> ";
}
$Pages = $Total / $per_page;
if ($Pages > 1) {
for ($b=0, $c=1; $b < $Pages; $b++, $c++) {
$check = $b * $per_page;
if ($check == $Result_Set) {
echo "<b>".$c." </b>";
}
if ($check != $Result_Set) {
$Res1 = $per_page * $b;
echo "<A HREF=\"$self?Result_Set=$Res1\">$c</A> ";
}
Last edited by 0beron; 03-29-2005 at 08:26 AM..
Reason: Added [php ] tags
|