Forum Moderators: coopster
I wrote the ASP page earlier this year and what it does is page through photos in a directory using two navigation buttons. Works great in ASP. Can it be done in PHP? If I'm barking up the wrong tree or asking too much, that's cool. I thought it would be worth a try to have some PHP genius here convert it for me so I wouldn't have to spend all of my free weekend trying to learn something I'll never use again.
Here's the code from my ASP page...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<TITLE>slide show</TITLE>
<%
Dim objFSO, objFolder, objPass
Set objFSO=Server.CreateObject("Scripting.FileSystemObject")
Set objFolder=objFSO.GetFolder("C:\WebSite1\Images\Jan04")
objPass = objFolder.Files.Count
Set objFolder = Nothing
Set objFSO = Nothing
%>
<script>
thisImg=1
function newSlide(direction)
{if(document.images)
{thisImg = thisImg + direction
if(thisImg<1)
{thisImg = <%=objPass%>}
if(thisImg > <%=objPass%>)
{thisImg = 1}
document.slider.src="file:///C:/WebSite1/images/Jan04/slide"+thisImg+".jpg"}}
</script>
</head>
<BODY BGCOLOR=WHITE>
<LEFT>
<TABLE BORDER=0 CELLPADDING=0
CELLSPACING=0>
<TR>
<TD VALIGN=BOTTOM>
</TD>
<TD>
<A HREF="javascript:newSlide(-1)">
<IMG height=56 width=35 SRC=file:///C:/WebSite1/graphics/prevbutton.jpg BORDER=0></A>
<IMG height=56 width=57 SRC="graphics/prev.jpg">
<A HREF="javascript:newSlide(1)">
<IMG height=75 width=104 SRC=file:///C:/WebSite1/graphics/nextbutton.jpg BORDER=0></A>
<IMG height=70 width=170 SRC=file:///C:/WebSite1/graphics/slideshowtext.jpg
ALIGN=LEFT><BR CLEAR=ALL>
<IMG SRC=file:///C:/WebSite1/images/Jan04/slide1.jpg NAME="slider">
</TD>
</TR>
</TABLE>
</LEFT>
</BODY>
</HTML>
How do I replace ASP code with PHP code to do this?
replace:
<%
Dim objFSO, objFolder, objPass
Set objFSO=Server.CreateObject("Scripting.FileSystemObject")
Set objFolder=objFSO.GetFolder("C:\WebSite1\Images\Jan04")
objPass = objFolder.Files.Count
Set objFolder = Nothing
Set objFSO = Nothing
%>
with
<?php
$filearray = array();
$handle = opendir('C:\WebSite1\Images\Jan04');
while($g = readdir($handle)){
if($g <> '.' && $g <> '..') $filearray[] $g;
}
$objpass = count($filearray);
?>
replace:
{thisImg = <%=objPass%>}
if(thisImg > <%=objPass%>)
with:
{thisImg = <?php echo $objpass;?>}
if(thisImg > <?php echo $objpass;?>)
good luck.