Jump to content

Readdir and one file ahead


imperium2335

Recommended Posts

How do I get my script to read the file ahead of the one that is currently selected?

 

I want to be able to inject two images, the current file and the next, then move to the next two etc.

 

The echo will be whats going to go into a file, that is later though.

 

$dir = "/" //Directory containing the images.

$openzone = @opendir($dir) ;

for($file = readdir($openzone))
{



$idnumber++ ;

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>' . "$title" . '</title>
<meta name="keywords" content="' . "$keywords" . '" />' . '
<meta name="description" content="" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="http://www.cake-photos.com/cakes-css.css" rel="stylesheet" type="text/css" />
</head>

<body>

<?PHP $currentimage =' . "$idnumber" . '
<div id="page"><?PHP include "/home/caketph/public_html/includes/headnav.html" ?>
<div id="head"></div>

<div id="search">
<?PHP include "/home/caketph/public_html/includes/header-search.html"?>
</div>

<div id="sidebar">
<?PHP include "/home/caketph/public_html/includes/sidenav.html" ?>
</div>
<div id="main">
<img src="' . "$firstimage" . '" class="ralign" />
<h1>' . "$headtag" . '</h1>
<h2></h2>

</div>
</div>

<div id="rightzone">
<?PHP include "/home/caketph/public_html/php/random.php" ; ?>

</div>

<div id="footer">
<?PHP include "/home/caketph/public_html/includes/footer.html" ; ?>


</div>


</body>
</html>' ;

}

Link to comment
Share on other sites

Hi, thanks for your help, but i tried another way and it worked:

 

I probly didnt explain what i wanted very well, sorry.

 

while($firstfile = readdir($openzone))
{

if($firstfile != '.' && $firstfile != '..' && !is_dir($dir.'/'.$firstfile))
{
	$firstimage = $dir . '/' . $firstfile ;

	$secondimage = $dir . '/' . readdir($openzone) ;

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.