Page 1 of 1

back forward button dosent work

Posted: Tue Jun 26, 2007 3:29 pm
by giliat
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hello
i try a simple script to manage pages on my site
i just want to incress +1 on press forward and to -1 on press back
what i need to had so it will work
thanks

Code: Select all

</head>

<body>
<form id="form1" name="form1" method="post" action="" target="_self">
<?php 

$totalpages = '7';


if (!(isset($pagenum)))// if no pages select or the firs display will be page 1
{ 
$pagenum = '1'; 
} 
if ($pagenum < '1') // if press back on page 1 stay in page 1
{ 
$pagenum = '1'; 
} 
if ($pagenum > $totalpages) // if press forward on last page stay in last page
{ 
$pagenum = $totalpages; 
}
echo "&#1506;&#1502;&#1493;&#1513; &#1502;&#1505;&#1508;&#1512; ",$pagenum,"<BR>";

//----- check buttons-----------
if (isset($_REQUEST['back'])){
$pagenum--;
}
if (isset($_REQUEST['first'])){
$pagenum == '1';
}
if (isset($_REQUEST['last'])){
$pagenum = $totalpages;
}
if (isset($_REQUEST['next'])){
$pagenum++;
}




?>
<table width="200" border="1">
  <tr>
    <td colspan="4">&#1506;&#1502;&#1493;&#1491; <? echo $pagenum ; ?> &#1502;&#1514;&#1493;&#1498; <? echo $totalpages?></td>
  </tr>
  <tr>
    <td>
    
      <input type="submit" name="back" id="back" value="&#1506;&#1502;&#1493;&#1491; &#1511;&#1493;&#1491;&#1501;" />
        </td>
    <td>      
        <input type="submit" name="first" id="first" value="&#1506;&#1502;&#1493;&#1491; &#1512;&#1488;&#1513;&#1493;&#1503;" />     
        </td>
    <td>
        <input type="submit" name="last" id="last" value="&#1506;&#1502;&#1493;&#1491; &#1488;&#1495;&#1512;&#1493;&#1503;" />
    </td>
    <td>
        <input type="submit" name="next" id="next" value="&#1506;&#1502;&#1493;&#1491; &#1492;&#1489;&#1488;" />
    </td>
  </tr>
</table>
</form>
</body>
</html>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Jun 26, 2007 3:33 pm
by superdezign
What about it doesn't work? And where does $pagenum come from?

Posted: Wed Jun 27, 2007 3:02 am
by Gente
You have to transfer $pagenum to your script. For this purpose use hidden form field.