General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 10th, 2003, 01:53 AM
mg03 mg03 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 7 mg03 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Displaying Page # in a Table

Hi. I have created a script that echo's database content in to a table. Now, what I want to do is have it display an increasing page # for each 5 rows. Ex:

P# | ID#
1 | 1
1 | 2
1 | 3
1 | 4
1 | 5
------
2 | 6
2 | 7
2 | 8
2 | 9
2 |10
------
3 |11
3 |12
3 |14
etc..


I hope you get the idea. If this is easy to do im gonna be mad . I've been messing around all day trying to figure this out and have finally done what I hate doing, get help.

Current code:

PHP Code:
// grab the users from the database and throw them in a table
$conf_v02 mysql_query("SELECT * FROM users");
$numrows  mysql_numrows($conf_v02);

WHILE (
$disp_v01 mysql_fetch_array($conf_v02)) {
    
$bgcolor = (++$i 1) ? '#0056E4' '#1F73FF';
    
$txclass = (++$j 1) ? 'style4'  'style4' ;
?>
<TR>
<TD WIDTH="14%" BGCOLOR="<?=$bgcolor;?>"><P ALIGN="center" CLASS="<?=$txclass;?>">PAGE # SHOULD GO HERE</TD>
<TD WIDTH="14%" BGCOLOR="<?=$bgcolor;?>"><P ALIGN="center" CLASS="<?=$txclass;?>" STYLE="margin-top: 3; margin-bottom: 3;"><? echo $disp_v01['id']; ?></TD>
<TD WIDTH="14%" BGCOLOR="<?=$bgcolor;?>"><P ALIGN="center" CLASS="<?=$txclass;?>"><? echo $disp_v01['name_f']; ?></TD>
<TD WIDTH="14%" BGCOLOR="<?=$bgcolor;?>"><P ALIGN="center" CLASS="<?=$txclass;?>"><? echo $disp_v01['name_l']; ?></TD>
<TD WIDTH="14%" BGCOLOR="<?=$bgcolor;?>"><P ALIGN="center" CLASS="<?=$txclass;?>"><? echo $disp_v01['name_u']; ?></TD>
<TD WIDTH="14%" BGCOLOR="<?=$bgcolor;?>"><P ALIGN="center" CLASS="<?=$txclass;?>"><? if ($disp_v01['seclvl'] == '2') { $thelvl 'Admin'; } elseif ($disp_v01['seclvl'] == '1') { $thelvl 'Moderator'; } else { $thelvl='Basic'; } ?><?=$thelvl?></TD>
<TD WIDTH="14%" BGCOLOR="<?=$bgcolor;?>"><P ALIGN="center" CLASS="<?=$txclass;?>"><? if ($disp_v01['locked'] == '1') { $islocked='Yes'; } else { $islocked='No'; } ?><?=$islocked;?></TD>
</TR>
<?
if (++$rowcount == && $rowcount $numrows) {
  echo 
'<tr><td colspan="7"><HR COLOR="#1F73FF" SIZE="1"></td></tr>';
}

}
// end loop 

Last edited by mg03 : July 10th, 2003 at 02:05 AM.

Reply With Quote
  #2  
Old July 10th, 2003, 02:10 AM
avit avit is offline
Not Yet Perfect
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: Squamish, BC
Posts: 111 avit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to avit
Hey hey,

Is this related to the other "group by 5" problem that I solved?

Yes, it should be simple enough to do. Put this in the beginning of your loop, before outputting the row.

PHP Code:
 $pagenumber floor(($rowcount+5) / 5); 

Reply With Quote
  #3  
Old July 10th, 2003, 02:15 AM
mg03 mg03 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 7 mg03 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks again. Works. I need to read up on the rounding functions. Just when I thought I was getting good at PHP.

Reply With Quote
  #4  
Old July 10th, 2003, 04:07 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Quote:
Originally posted by mg03
Thanks again. Works. I need to read up on the rounding functions. Just when I thought I was getting good at PHP.
Actually, it would serve you well as a programmer to understand some of the basic Math related functions that are common in pretty much all programming languages. Rounding is pretty standard, so you should get familiar with these functions now and you will find you will be quick to solve other related problems much quicker.

Quote:
I've been messing around all day trying to figure this out and have finally done what I hate doing, get help.
You should never hate to get help. Getting help is a good thing.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #5  
Old July 10th, 2003, 04:10 AM
mg03 mg03 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 7 mg03 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Maybe so, but I have a hard time understanding how the code operates when someone just gives it to me. Its hard for me to figure out how it does what it does.

Reply With Quote
  #6  
Old July 10th, 2003, 04:39 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
PHP has many formats of it's manual available for download.
HTML, PDF, PalmPilot, and HTML Help file.

You can get them from here: http://www.php.net/download-docs.php

This should help you out if you need to quickly reference the manual to find out if a particular function is available.

Most of the time, if you can figure out a way to solve a problem, there is a function available that can help you solve it.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Displaying Page # in a Table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT