Arkane Posted February 17, 2009 Share Posted February 17, 2009 Hey guys, Sorry if the topic is misleading, I couldn't think of an explanation for this. I'm trying to add images to my site automatically. It's using numbers and I already have the code for most of it. The problem is that the source images are kept in folders to seperate the files more. My script adds the links according to a 4 digit number, but each file is kept in subfolders, so 0001.png is in imgs/0001-0250/, with the folders always increasing in 250 increments. Can anyone help me for some script to calculate the number so that it can all be done automatically? Cheers guys Quote Link to comment Share on other sites More sharing options...
drisate Posted February 17, 2009 Share Posted February 17, 2009 show us the code you have right now. That will help understand what your saying. PHP is more clearn then English sometimes hehe Quote Link to comment Share on other sites More sharing options...
allworknoplay Posted February 17, 2009 Share Posted February 17, 2009 show us the code you have right now. That will help understand what your saying. PHP is more clearn then English sometimes hehe Agreed, also, it would help to provide a list of examples of the output that you are expecting... Quote Link to comment Share on other sites More sharing options...
alphanumetrix Posted February 17, 2009 Share Posted February 17, 2009 please give an example of your code. Quote Link to comment Share on other sites More sharing options...
Arkane Posted February 17, 2009 Author Share Posted February 17, 2009 Ok guys, here's the code I have atm. <?php $startnum = isset($_GET['startnum']) ? $_GET['startnum'] : '0001'; $endnum = $startnum + 99; $books = new SimpleXMLElement('NDS.xml', null, true); echo '<h2>'.sprintf('%04d', $startnum).' to '.sprintf('%04d', $endnum).'</h2><p>'.PHP_EOL; $titles = $books->xpath('games/game'); foreach($titles as $title) { $num = $title->releaseNumber; if (($num >= $startnum) && ($num <= $endnum)) { $romnum = sprintf('%04d', $num); $imgfile = 'imgs/0001-0250/'.$romnum.'.jpg'; echo '<img src="' . $imgfile . '">'; } } echo '</p>'; ?> Obviously, it doesnt work if the img number is higher than 250, and since it now goes up to 3000 I figure I need a script rather than just an if then else. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.