Jump to content


Photo

Paging, Multicategory


  • Please log in to reply
5 replies to this topic

#1 elhama

elhama
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 11 August 2006 - 12:14 AM

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:
<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>


#2 elhama

elhama
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 11 August 2006 - 01:46 AM

bump

#3 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 11 August 2006 - 01:57 AM

I would try to help you, but what youre sayin makes no sense at all...
Why doesn't anyone ever say hi, hey, or whad up world?

#4 Lessur

Lessur
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 11 August 2006 - 02:09 AM

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

?


#5 elhama

elhama
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 11 August 2006 - 02:20 AM

Yes lessur, thats exactly what I'm trying to do...

#6 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 11 August 2006 - 12:25 PM

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users