Jump to content

Number Sequence


Arkane

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.