Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
List of numbers, reset by every page.
Old 09-20-2007, 04:25 PM List of numbers, reset by every page.
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
Say you have 30 apples in your basket and you want to seperate it to 10 on every table. 10 apples per table right? There will be no number 1's except for the one that is started on table 1.

Table 1: 1,2,3,4,5,6,7,8,9,10
Table 2: 11,12,13,14... etc

Everytime I go to a new "table" the numbers get reset:

Table 1: 1,2,3,4,5,6,7,8,9,10
Table 2: 1,2,3,4,5,6,7,8,9,10

How can I overcome this?

Note: Using MySQL to pull out the data and using "<ol><li>$item</li></ol>" to display the data.

Thanks

Last edited by feraira; 09-21-2007 at 02:55 PM.. Reason: Fixed ul to ol
feraira is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-20-2007, 09:03 PM Re: List of numbers, reset by every page.
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Can you show us the code which isn't resetting? That'd make suggesting a solution easier.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 09-21-2007, 01:19 AM Re: List of numbers, reset by every page.
Novice Talker

Posts: 9
Trades: 0
if you mean a list with automatic number you should use <ol> instead of <ul>:

<ol>
<li>sdfd</li>
<li>dfsds</li>
<li>fdsfds</li>
...
</ol>

<ol start="10" >
<li>sdfd</li>
<li>dfsds</li>
<li>fdsfds</li>
...
</ol>

<ol start="20" >
<li>sdfd</li>
<li>dfsds</li>
<li>fdsfds</li>
...
</ol>

You don't have the choice to set the "start" manually since you have to separate your list in 3.
Bakunin is offline
Reply With Quote
View Public Profile
 
Old 09-21-2007, 02:52 PM Re: List of numbers, reset by every page.
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
Quote:
Originally Posted by Bakunin View Post
if you mean a list with automatic number you should use <ol> instead of <ul>:

<ol>
<li>sdfd</li>
<li>dfsds</li>
<li>fdsfds</li>
...
</ol>

<ol start="10" >
<li>sdfd</li>
<li>dfsds</li>
<li>fdsfds</li>
...
</ol>

<ol start="20" >
<li>sdfd</li>
<li>dfsds</li>
<li>fdsfds</li>
...
</ol>

You don't have the choice to set the "start" manually since you have to separate your list in 3.
I meant OL Sorry.

Working example: http://hotcasket.com/cat.php?catID=4

That is in a "ordered list" format; except it gets reset by every page change.

As for the code?

Code:
	<ol><li><a href="tutorial.php?tutID=$id" title="$title">$title</a></li></ol>
	<p class="tut_desc">$desc</p>
feraira is offline
Reply With Quote
View Public Profile
 
Old 09-21-2007, 06:34 PM Re: List of numbers, reset by every page.
Novice Talker

Posts: 9
Trades: 0
ok, all you have to do is use a variable "start" in your <ol>


<ol start="$start">

and you give the var $start the number you want it to be,
if you show 15 per page you could do:

$start = ($_GET['page']-1*15);

or your $start var you use in your query.
Bakunin is offline
Reply With Quote
View Public Profile
 
Old 09-22-2007, 05:38 AM Re: List of numbers, reset by every page.
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
That seems very logical!
Although, I have tried this and it still doesn't work
feraira is offline
Reply With Quote
View Public Profile
 
Old 09-22-2007, 11:15 AM Re: List of numbers, reset by every page.
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
I think it would help people help you if you posted the php/mysql code your using to pull the information out of the database and display it.
joder is offline
Reply With Quote
View Public Profile
 
Old 09-23-2007, 01:42 PM Re: List of numbers, reset by every page.
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
cat.php

for($x = 0; $c = mysql_fetch_array($sqlnew); $x++) {

$title = $c['title'];
$desc = $c['desc'];
$id = $c['id'];

if(empty($desc)) {
$desc = "No Description.";
}

$start = ((($_GET['page'])-1)*15);

eval ("\$main_tut = \"".gettemplate("category_tuts")."\";");
echo $main_tut;

}

category_tuts.html

<li><a href="tutorial.php?tutID=$id" title="$title">$title</a></li>
<p class="tut_desc">$desc</p>


obviously with a template above and below that section of code opening and closing the "<ol>".
feraira is offline
Reply With Quote
View Public Profile
 
Old 09-24-2007, 06:00 PM Re: List of numbers, reset by every page.
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
Fixed. I placed the $start variable underneath the template when it was echo'd out.. Meaning that the variable didn't exist when being used in the template!!

Schoolboy error!

Thanks though, works a treat. Except.. I fiddled around with it because it didn't work exactly as it should have.. Here is what I came up with to get the PERFECT results:

Code:
$start = ((($_GET['page']-1)*15)+1);
-1 to get one less than the page number, multiply that by 15 to get the correct amount (shown per page.. can change) and then +1 because it'll be -1 to what value it wants.. Meaning it will start @ 0 and not 1. Adding 1 simply means it'll start at 1

Thanks
feraira is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to List of numbers, reset by every page.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.37525 seconds with 12 queries