|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
Simplexml problem
Hello,
i don't know if this is the good place to post this request. I am totally newbie in php and in xml, i am trying to use simplexml with php5. I'm trying to use an xml feed with quite big content. I have more than 100 items in this xml feed. I have read several documentation but can't get the result i want. Here is my actual code: <?php $request_url = "http://****************/3164.xml"; $xml = simplexml_load_file($request_url) or die("feed not loading"); foreach ($xml->channel as $channel) { foreach ($channel->item as $item) { ?> <a href="<?php printf($item->link); ?>" target="_blank"><strong><?php printf($item->title); ?></strong></a> <?php printf($item->description); ?> <?php } } ?> I can get the xml feed show on my page, but got a huge page with more than 100 items on it. What i am trying to do is to split the xml feed content on multiple page, and show 10 items on each page. Can anybody give me an example of the code i should use on page 1 to show item from 1 to 10 and the code i should use on page 2 showing items from 11 to 20? Thanks for any help or suggestion, ica |
|
#2
|
|||
|
|||
|
One way would be to have a counter, and a minimum and maximum
I can't recall PHP syntax, so this will be pseudocode: initialize counters counter = 0; page = 1; itemsPerPage = 10; maximum = page * itemsPerPage; minimum = maximum + 1 - itemsPerPage; inside your second for loop counter++; if (counter < minimum) continue; else if (counter < maximum) output; else break; |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Simplexml problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|