PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
spamyboy
Forum Contributor
Posts: 266 Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius
Post
by spamyboy » Thu Oct 11, 2007 4:10 pm
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
(curent page is five)
I think you got my idea.
Pleas help and thank you.
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Thu Oct 11, 2007 6:50 pm
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;
}
(#10850)
spamyboy
Forum Contributor
Posts: 266 Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius
Post
by spamyboy » Fri Oct 12, 2007 12:37 am
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 ?
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Fri Oct 12, 2007 3:40 am
Can you explain in very specific term what you want to be displayed when you have various numbers of pages?
(#10850)