Page 1 of 1
Just started on PHP, need help :S
Posted: Mon Feb 17, 2003 4:00 pm
by Makkie
Hello people,
I'm just new hear.
I bought a book on PHP, read through the most part allready, and wanted to make a script to make a photo "slide show".
This is my code:
<?php
for ($pic= 1; $pic<23; $pic++)
{
('<a href="
http://www.apollorecordingstudio.com/ki ... brrr/.$pic. .html" target=_down><img src="
http://www.apollorecordingstudio.com/next.gif"></a>');
}
?>
I want the code to show a little button(next.gif) which refers to *$pic*.hmtl.
$pic should add 1 everytime one clicks the button
It is probably all wrong, but can someone tell me what to change, and why?
thanks in advance for your help!
greetz,
Makkie
Posted: Mon Feb 17, 2003 4:21 pm
by patrikG
Try the following:
Code: Select all
<?php
for ($pic= 1; $pic<23; $pic++)
{
echo "<a href="http://www.apollorecordingstudio.com/kids/pics/brrr/".$pic.".html" target=_down><img src="http://www.apollorecordingstudio.com/next.gif"></a>'";
}
?>
This presumes that you've named you are loading files names "1.html" to "22.html" into a frame called "_down".
Is this what you were looking for?
error
Posted: Mon Feb 17, 2003 4:46 pm
by Makkie
Thanks for your help.
i'm getting an error:
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /usr/local/psa/home/vhosts/apollorecordingstudio.com/httpdocs/next.php on line 6
i can't find the error in the code.. can you?
Posted: Mon Feb 17, 2003 4:58 pm
by Makkie
if i replace the " surrounding the link and the image source by a ' i get a whole row of next buttons(22 of em, as many as the $pic var) and they link to
http://www.apollorecordingstudio.com/ki ... pic.".html
this isn't exactly what i want to do with the script

Posted: Mon Feb 17, 2003 5:04 pm
by Makkie
still trying,
i edited the code like this
Code: Select all
<?php
for ($pic= 1; $pic<23; $pic++)
{
echo '<a href="http://www.apollorecordingstudio.com/kids/pics/brrr/' . $pic . '.html"\ target=_down><img
src="http://www.apollorecordingstudio.com/next.gif"></a>';
}
?>
and now i still get the 22 next buttons, but they do link to the right file.
Now i need to make the $pic var add a number when clicked on the next button...
any ideas?
Posted: Mon Feb 17, 2003 5:16 pm
by Makkie
i now replaced the next button by another .$pic. so i have a list in the upper frame wich counts from 1 to 23 so i can click the numbers now.
But i still prefer to click a next button or link, so i can watch the photo's one by one just clicking next....
is that possible anyway?
Posted: Mon Feb 17, 2003 5:37 pm
by volka
yes, e.g. by passing the picture-number to the script.
Code: Select all
<?php
if (!isset($_GET['pic']))
$pic = 1;
else
$pic = max((int)$_GET['pic'], 0)+1;
?>
<html><head><title>picture #<?php echo $pic; ?></title></head>
<body>
<a href="<?php echo $_SERVER['PHP_SELF'], '?pic=', $pic;?>" >next</a>
<img src="/path/to/images/<?php echo $pic; ?>.ext" />
<a href="<?php echo $_SERVER['PHP_SELF'], '?pic=', $pic;?>" >next</a>
</body>
</html>
(script not even tested by compiler)
this will increment the number passed via
pic by one, show the according image and use the incremented number as new parameter for the link (so you can step through one by one).
You have to change the image-pat and the extension (might be .gif or .jpg or ...).
The script should also check wether there is a next image.
do not worry about the
max((int)$_GET['pic'], 0), it's only to assure that the paramter
pic is a number and not negative.
Posted: Tue Feb 18, 2003 5:42 am
by Makkie
thanks! wil try tonight, i can´t upload anything here, i´m at work right now and they are blocking uploading("%&#&#%&_).
I´ll let you know if i got it to work.
thanks again!
Posted: Tue Feb 18, 2003 4:09 pm
by Makkie
Works great!
I changed the code a bit so i can now show next and previous picture.
Had to puzzle a bit, but it works magnificent right now!
thanks for the support
seeya guys