Forum Moderators: coopster

Message Too Old, No Replies

Simple PHP question

         

mazoboom

11:02 pm on Sep 7, 2004 (gmt 0)

10+ Year Member



I'm trying to use PHP to make a "Next" and "Previous" buttons to change numbers on sequential files. I can't get it to work. Here is part of the code that I'm using:

<?php
echo <<<END
<img src="$imagename"><br>

<table>
<tr>
<td><a href="archive.php?comic=1">First</a></td>
<td><a href="archive.php?comic=--$comic">Previous</a></td>
<td><a href="archive.php?comic=++$comic">Next</a></td>
<td><a href="archive.php?comic=$maxcomics">Last</a></td>
</table>
END;
?>

It's Previous and Next that I can't figure out. Is it it the echo method I'm using? Or can you not add to variables like that?

Zipper

11:08 pm on Sep 7, 2004 (gmt 0)

10+ Year Member



try saving the prev, next values in two seperate variables and use them to generate the links.

mincklerstraat

10:50 am on Sep 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're using 'heredoc' format, which is documented at [be2.php.net...] . Can be handy, but you do need to know what you're doing. I'd take the above commentator's advice, but be sure to do it above the echo <<<END line.
Like,
$previous = $comic - 1;
$next = $comic++;
echo <<<END (...)

mazoboom

12:24 pm on Sep 8, 2004 (gmt 0)

10+ Year Member



Thanks, I often fail to see simple solutions.