Jump to content

Archived

This topic is now archived and is closed to further replies.

elhama

Paging, Multicategory

Recommended Posts

Alright, Didn't get any good responds yesterday so I try again, my thread kinda died..

So the problem is now that I have to limit the data to a max of 25 per page, which is simple by itself, but also what I have to do is to keep it categorized, and I just can't seem to get through with it, can someone enlighten me please?

Here is some example code I've tried to fix, but it keeps messing up! The loops gets screwed up..



Here's what I want to get

Category 1
- Comment 1
- Comment 2
Category 2
- Comment 1
- Comment 2



Note: This is only testing/example code of what I'm meaning

Code:
[code]
<b>
<?
echo "<table border=1>";
if(!isset($_GET['page'])){
        $numPage = 1;
}
else{
        $numPage = $_GET['page'];
}
$rowsPerPage = 2;
$offset = ($numPage - 1) * $rowsPerPage;
$testy = mysql_fetch_array(mysql_query("SELECT category FROM myfriends limit $offset, 1"));
$test = mysql_query("SELECT * FROM myfriends limit $offset, $rowsPerPage");
$category=$testy[category];
while(($category < 5) && ($t = mysql_fetch_array($test))){
        if($category==1)
        $cat_text = "Friends";
        if($category==2)
        $cat_text = "Family";
        if($category==3)
        $cat_text = "School";
        if($category==4)
        $cat_text = "The Rest";
        echo "<tr><td>$cat_text</td></tr>";
        $test3 = mysql_query("SELECT * FROM myfriends where category='$category' limit $offset, $rowsPerPage") or die(mysql_error());

                while($e = mysql_fetch_array($test3)){

                echo "<tr><td>$e[comment]</td></tr>";


                }
$category = $category+1;
}
echo "</table>";
$topage = $numPage +1;
echo "<a href=test.php?page=$topage>></a>";
?>
</b>
[/code]

Share this post


Link to post
Share on other sites
I would try to help you, but what youre sayin makes no sense at all...

Share this post


Link to post
Share on other sites
Is whast you want is like an outline?

I. Category 1
  A. Comment 1
  B. Comment 2
II. Catergory 2
  A. Comment 1
  B. Comment 2

?

Share this post


Link to post
Share on other sites
what you wont?

1st page
cat1
-com1
-com2
cat2
-com1
next page
cat2
-com2
cat3
-com1
-com2

or

1st page
cat1
-com1
cat2
-com1
cat3
com1
next page
cat1
-com2
cat2
-com2
cat3
-com2

Share this post


Link to post
Share on other sites

×

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.