Jump to content
alexarpad2003

Php Mysql pagination

Recommended Posts

Posted

Am codul :

<?php

if (isset($_GET['startrow']) or is_numeric($_GET['startrow']))

{

$startrow = (int)$_GET['startrow'];

}

@require("aaa.php");

$q='select * from table where bbb="ccc" limit '.$startrow.', 5';

$rez=$db->query($q);

for($i=1;$i<=$rez->num_rows-0;$i++) {

$row=$rez->fetch_object();

$pret_lei=ceil($row->pret*$_SESSION['EUR']);

$out='

<table width="530" cellspacing="5" cellpading="0" border="0">

<tr>

<td width="90" style="border: 1px solid #c5c5c5;font-size: 14px" align="center"><img width="70" height="60" src="http://aaa/'.$row->cod.'.jpg"></td>

<td width="30"></td>

<td width="230" style="font-size: 15px" align="left"><b>'.$row->marca.'</b><br><font style="color:#555">'.$row->denumire.'</font></td>

<td width="110" style="font-size: 14px" align="center"><font style="color:#555">'.$row->pret.' € / buc</font><br><font style="color:#000">( '.$pret_lei.' lei )</font></td>

</tr>

</table>';

echo $out."";

}

echo '<a style="color:#000;text-decoration:none" href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow-5).'"><<</a>

<a style="color:#000;text-decoration:none" href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+5).'">>></a>';

?>

Numai ca href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow-5) si href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+5) imi duc valori de -5 si +5 pana la "infinit" chiar daca nu mai afiseaza nimic pe pagina. Vreau ca atunci cand nu mai sunt valori de afisat sa dispara >>

Cum fac ?

Posted

nu ma pricep dar cred ca

if (isset($_GET['startrow']) or is_numeric($_GET['startrow']))

{

$startrow = (int)$_GET['startrow'];

}

aici trebuie un else... nuj sigur. in rest nu am vazut nimic special (chiar nu ma pricep. daca gresesc nu ma injura)

Posted (edited)
<?php
if (isset($_GET['startrow']) or is_numeric($_GET['startrow']))
{

$startrow = (int)$_GET['startrow'];

}

@require("aaa.php");
$q='select * from table where bbb="ccc" limit '.$startrow.', 5';
$rez=$db->query($q);

for($i=1;$i<=$rez->num_rows-0;$i++) {
$row=$rez->fetch_object();

$pret_lei=ceil($row->pret*$_SESSION['EUR']);
$out = '
<table width="530" cellspacing="5" cellpading="0" border="0">
<tr>
<td width="90" style="border: 1px solid #c5c5c5;font-size: 14px" align="center"><img width="70" height="60" src="http://aaa/'.$row->cod.'.jpg"></td>
<td width="30"></td>
<td width="230" style="font-size: 15px" align="left"><b>'.$row->marca.'</b><br><font style="color:#555">'.$row->denumire.'</font></td>

<td width="110" style="font-size: 14px" align="center"><font style="color:#555">'.$row->pret.' € / buc</font><br><font style="color:#000">( '.$pret_lei.' lei )</font></td>


</tr>
</table>';
echo $out."";
}

$q='select * from table where bbb="ccc" limit ' . ($startrow-5) . ', 5';
$rez=$db->query($q);
if($rez->num_rows)
echo '<a style="color:#000;text-decoration:none" href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow-5).'"><<</a>';

$q='select * from table where bbb="ccc" limit ' . ($startrow+5) . ', 5';
$rez=$db->query($q);
if($rez->num_rows)
echo '<a style="color:#000;text-decoration:none" href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+5).'"><<</a>;

?>

Edited by jesus

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...