Page 1 of 1

paging help

Posted: Thu Oct 11, 2007 4:10 pm
by spamyboy

Code: Select all

function paging($query_var, $from){
global $dSystem;

$eu = ($from - 0); 
$limit = 20;
$this1 = $eu + $limit; 
$back = $eu - $limit; 
$next = $eu + $limit;

$queryNumberOfResults = $dSystem->db->query("$query_var");
$numberOfResults=mysql_num_rows($queryNumberOfResults);

$query = $query_var. " limit $eu, $limit ";
$result = $dSystem->db->query("$query");

while($row=$dSystem->db->fetch_array($result))
{
echo "<a href=\"?switch=translate-by-id&word-id=".$row['id']."\"><strong>".$row['term']."</strong> - ".$row['translation']."</a><br />"; 
}
if($back >=0) {print "<a href='?switch=letter&from=$back'>prev</a>";}

$i=0;$l=1;
for($i=0;$i < $numberOfResults;$i=$i+$limit){
if($i <> $eu){echo "<a href='?switch=letter&$page_name?from=$i'>$l</a> ";}else { echo "$l";}
$l=$l+1;
}

if($this1 < $numberOfResults) {print "<a href='?switch=letter&?from=$next'>next</a>";}
}
All works, just insted of this:

Code: Select all

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
I need to get smth like this

Code: Select all

...3..4.5.6..7...
(curent page is five)
I think you got my idea.
Pleas help and thank you.

Posted: Thu Oct 11, 2007 6:50 pm
by Christopher
Then modify this part of the code to do that:

Code: Select all

$i=0;$l=1;
for($i=0;$i < $numberOfResults;$i=$i+$limit){
if($i <> $eu){echo "<a href='?switch=letter&$page_name?from=$i'>$l</a> ";}else { echo "$l";}
$l=$l+1;
}

Posted: Fri Oct 12, 2007 12:37 am
by spamyboy
i din't asked that, I asked how ? I can't get it out.
is should be smth like $-- $---- and so on, but I don't understand IF logic.
Could you help with code ?

Posted: Fri Oct 12, 2007 3:40 am
by Christopher
Can you explain in very specific term what you want to be displayed when you have various numbers of pages?