View Single Post
  #2 (permalink)  
Old 2008-03-15, 05:25 PM
mattisdada mattisdada is offline
Junior Member
 
Join Date: Mar 2008
Posts: 6
mattisdada is on a distinguished road
Default

I had a huge long reply with explanation on everything(And then i accedentally quit opera), but anyway, for future refrence this is the solution.

Code:
<?php
session_start();
session_register("comic");
if ($_SESSION['comic'] < 1){$_SESSION['comic'] = 1;}

$Next_Prev = $_POST['Next_Prev'];
switch ($Next_Prev)
{
case 'Next':
$_SESSION['comic']++;
break;
case 'Prev':
if ($_SESSION['comic'] == 1){$_SESSION['comic'] = 1;}else {$_SESSION['comic']--;}
break;
}

echo $_SESSION['comic'];
?>

<body>
<img src="comic/<?=$_SESSION['comic']?>.jpg">

<form name="Next_Prev" method="post" action="">
  <input type="submit" name="Next_Prev" id="Next" value="Next">
  <input type="submit" name="Next_Prev" id="Prev" value="Prev">
</form>
</body>
My finnished comic engine project(Ill be making a theme engine for it soon enough)

comic.php
Code:
<?php
session_start();
session_register("comic");
require("config.php");
if ($_SESSION['comic'] < 1){$_SESSION['comic'] = 1;}
//print count(glob($comic_dir . "/*." . $ext . ""));
$Next_Prev = $_POST['Next_Prev'];
switch ($Next_Prev)
{
case 'Next':
$_SESSION['comic']++;
break;
case 'Prev':
if ($_SESSION['comic'] == 1){}else {$_SESSION['comic']--;}
break;
case 'First':
$_SESSION['comic'] = 1;
break;
case 'Latest':
$_SESSION['comic'] = count(glob($comic_dir . "/*." . $ext));
break;
}
echo $_SESSION['comic'];
?>
<body>
<img src="comic/<?=$_SESSION['comic']?>.jpg">
<form name="Next_Prev" method="post" action="">
  <input type="submit" name="Next_Prev" id="First" value="First">
  <input type="submit" name="Next_Prev" id="Prev" value="Prev">
  <input type="submit" name="Next_Prev" id="Next" value="Next">
  <input type="submit" name="Next_Prev" id="Latest" value="Latest">
</form>
</body>
config.php
Code:
<?php
// The directory of the comic's.
$comic_dir = "comic";
//The file extension your comics use.
$ext = "jpg";
?>
But for tyhis to be fully complete i need to know how to GET_ the comic variable.

Last edited by mattisdada; 2008-03-16 at 06:47 AM.
Reply With Quote