Just started on PHP, need help :S
Moderator: General Moderators
Just started on PHP, need help :S
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
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
Try the following:
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?
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>'";
}
?>Is this what you were looking for?
error
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?
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?
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
this isn't exactly what i want to do with the script
still trying,
i edited the code like this
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?
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>';
}
?>Now i need to make the $pic var add a number when clicked on the next button...
any ideas?
yes, e.g. by passing the picture-number to the script.(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.
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>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.