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
Old 06-27-2006, 08:57 PM fread or arrays
randomlande's Avatar
Skilled Talker

Posts: 63
Trades: 0
lets say i have 100 items and only want to show 20 on each page, but i dont want to use a database. i know u can use arrays, but how exactly can i tell it to take lets say numbers 40-59 in the arrays list and display it.

also can i do it in a txt file and use fread to read each one off a specific line?

maybe with File()?

Last edited by randomlande; 06-27-2006 at 09:02 PM..
randomlande is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-27-2006, 09:19 PM Re: fread or arrays
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Using file() will read the file into an array by line. So then you could count() the lines returned from the file, use display a selected range by calling the array keys numerically.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-27-2006, 09:37 PM Re: fread or arrays
randomlande's Avatar
Skilled Talker

Posts: 63
Trades: 0
how do i display a range of items from an array without listing each one and telling it to display
randomlande is offline
Reply With Quote
View Public Profile
 
Old 06-27-2006, 10:15 PM Re: fread or arrays
ChancesAre's Avatar
Skilled Talker

Posts: 84
Trades: 0
echo $line[49] ?
ChancesAre is offline
Reply With Quote
View Public Profile
 
Old 06-28-2006, 03:45 AM Re: fread or arrays
Skorch1's Avatar
Super Talker

Posts: 115
Location: California
Trades: 0
I would use a looped counter
Code:
<?php
$start_number = 1; // I would put this in the linking page's url
$limit = 19 + $start_number;
$counter = $start_number;
$counter--;
Do
{
echo $arrays_list[$counter]; // You can name it whatever you want
$counter++;
}
WHILE($counter <= $limit);
?>
I used three numbers so when I was done with the loop I could reference my starting point. I only added 19 to the start number because i'm going to decrement the counter by 1 gigit becaue arrays start at 0 while it's easier to count from 1 ( I've read alot of books and they all start on page 1). This will echo 20 array values and stop. I would link to it using a dynamic url so <a href="/page.php?start=1">Page Set 0-19</a><a href="page.php?start=20">Page Set 20-39</a> etc.
__________________
Check out my
Please login or register to view this content. Registration is FREE
website!

Last edited by Skorch1; 06-28-2006 at 03:47 AM..
Skorch1 is offline
Reply With Quote
View Public Profile Visit Skorch1's homepage!
 
Old 06-29-2006, 01:18 PM Re: fread or arrays
randomlande's Avatar
Skilled Talker

Posts: 63
Trades: 0
Aha, ok thanks guys got it
randomlande is offline
Reply With Quote
View Public Profile
 
Old 06-29-2006, 01:20 PM Re: fread or arrays
randomlande's Avatar
Skilled Talker

Posts: 63
Trades: 0
another quick question, if for example i have this:

http://site.com/page.php?url=http://site2.com/?l=1&b=2

how can i have it so that the variables in site2's url dont affect the main site url (eg the whole site2 url is one variable)
randomlande is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to fread or arrays
 

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.25217 seconds with 12 queries