| | #1 |
| Active Warrior War Room Member Join Date: 2009
Posts: 70
Thanks: 7
Thanked 9 Times in 7 Posts
|
Can anyone point me to some php code that will loop through an xml feed and display the contents horizontally? I can loop through the feed and have the results displayed vertically but I have no clue how to get them horizontal. This is how I get the results vertical. PHP Code: title1 title2 title3 I would like title1 title2 title3 Thanks! |
| |
| | #2 |
| Advanced Warrior War Room Member Join Date: 2004 Location: Perth, Australia.
Posts: 724
Thanks: 6
Thanked 184 Times in 136 Posts
|
The code you have should display them horizontally becuase there is not "break" being issed at the end of each echo statement. What might be happeining is that the data coming from the xml file contains embedded <br> or <br /> statments. So try something like this, to see if this fixes the problem: foreach($xml->Foods->Food as $Food){ $title = str_replace('<br>','',str_replace('<br />','',$Food->Title)) ; echo $title; Its not pretty, its only test code.. Hope this helps Bruce |
| |
| | #3 |
| PHP Programmer War Room Member Join Date: 2009 Location: /dev/null
Posts: 138
Thanks: 6
Thanked 12 Times in 12 Posts
|
Your code should all display in one line. If it doesn't you can try something like this. foreach($xml->Foods->Food as $Food){ $title = $Food->Title ." "; echo $title; // Or add it here. // or just echo this echo $Food->Title . " "; } If you add a space to the end of the title, it should just force it into one line with a space. --m4rx |
| We are what we repeatedly do. Excellence, then, is not an act, but a HABIT. ~Aristotle Bored. Learn everything you need to know about Organic Gardening. | |
| |
| | #4 |
| Active Warrior War Room Member Join Date: 2009
Posts: 70
Thanks: 7
Thanked 9 Times in 7 Posts
|
I would like to display it in 3 columns like this and then continue down the page with a total of ten results. Item1 item2 item3 picture1 picture2 pciture3 price1 price2 price3 link1 link2 link3 like this |
| Last edited on 17th Feb 2010 at 04:32 PM. Reason: did not dislpay correctly | |
| |
| | #5 |
| Advanced Warrior War Room Member Join Date: 2004 Location: Perth, Australia.
Posts: 724
Thanks: 6
Thanked 184 Times in 136 Posts
|
I would suggest putting this up as a simple job on RentAcoder and get someone to do the job much faster than waiting for other people here to write your code for you. I'm sure you get a job like this done for $10 - $50 .. Maybe even a lot less Give it a try Bruce |
| |
|
| Bookmarks |
| Tags |
| foreach, horizontal, loop, php |
| |