bgbs Posted April 17, 2008 Share Posted April 17, 2008 With this script below the 6 pics appear in one row, I would like them to appear in two rows, so three pics in each row and I dont know how to do that. Any help would be appreciated Thanks ahead of time Ben <?php $tags = "sea, sand, caribe, sunshine"; $imageNumber = 6; function getFlickrRSS(){ global $tags, $ids; $url = "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2&tags=".$tags; if ($fp = fopen($url, 'r')) { $content = ''; while ($line = fread($fp, 1024)) { $content .= $line; } } return $content; } function getImages($rssContent){ global $imageNumber; $before = '<media:thumbnail url="'; $after = '"'; $imageList = array(); $oldPos = 0; $startPos=0; do { $oldPos = $startPos; $startPos = strpos($rssContent,$before,$startPos) + strlen($before); $endPos = strpos($rssContent,$after,$startPos); $imageList[] = substr($rssContent,$startPos,$endPos-$startPos); } while (($startPos > $oldPos) && (sizeof($imageList)<$imageNumber)); return $imageList; } $content = getFlickrRSS(); $imageList = getImages($content); ?> Link to comment https://forums.phpfreaks.com/topic/101582-need-simple-help-with-fix/ Share on other sites More sharing options...
jonsjava Posted April 17, 2008 Share Posted April 17, 2008 You posted this yesterday, and I started to work on it, and had it almost done, and my IDE crashed (too many things open). I usually hate reposts, but in this case, thanks! Link to comment https://forums.phpfreaks.com/topic/101582-need-simple-help-with-fix/#findComment-519625 Share on other sites More sharing options...
Zhadus Posted April 17, 2008 Share Posted April 17, 2008 for ($x = 0; $x < sizeof($imageList); $x++) { if (($x%(ceil($imageNumber/2)) == 0) && ($x !== 0)) { echo "<br>"; } echo "<img src='$imageList[$x]'>"; } That is going to be the simple version. Because of the ceil() function, you can also change the amount of images you want to use and it will always display 2 rows and if it's an uneven amount, the 2nd row will have the missing slot. Link to comment https://forums.phpfreaks.com/topic/101582-need-simple-help-with-fix/#findComment-519658 Share on other sites More sharing options...
jonsjava Posted April 17, 2008 Share Posted April 17, 2008 also, you will need to alter some of the data striping, because the rss xml is different for the user pages. Link to comment https://forums.phpfreaks.com/topic/101582-need-simple-help-with-fix/#findComment-519666 Share on other sites More sharing options...
bgbs Posted April 18, 2008 Author Share Posted April 18, 2008 Can you tell me exactly where I stick this code? for ($x = 0; $x < sizeof($imageList); $x++) { if (($x%(ceil($imageNumber/2)) == 0) && ($x !== 0)) { echo "<br>"; } echo "<img src='$imageList[$x]'>"; } That is going to be the simple version. Because of the ceil() function, you can also change the amount of images you want to use and it will always display 2 rows and if it's an uneven amount, the 2nd row will have the missing slot. Link to comment https://forums.phpfreaks.com/topic/101582-need-simple-help-with-fix/#findComment-520496 Share on other sites More sharing options...
Zhadus Posted April 18, 2008 Share Posted April 18, 2008 Stick it at the end of the code or wherever you want it to be displayed (Assuming it's after that bit of code and on the same page). Link to comment https://forums.phpfreaks.com/topic/101582-need-simple-help-with-fix/#findComment-520507 Share on other sites More sharing options...
bgbs Posted April 18, 2008 Author Share Posted April 18, 2008 ok cool that worked Thanks man. I had couple of more questions if you have time helping. Originally I wanted the script to show only my flickr gallery pics from a particular set. Not from tags, like it is doing right now. The user path and ID is "http://www.flickr.com/photos/25721203@N05/" and set is "warren" And the other thing I wanted the script to do is make the pictures clickable so that when you click on them it takes you to the flickr page to view your picture. Thanks Link to comment https://forums.phpfreaks.com/topic/101582-need-simple-help-with-fix/#findComment-520520 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.