Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 05-08-2008, 01:43 AM Pagination help?
Extreme Talker

Posts: 189
Trades: 0
php code

PHP Code:
<?php
$sortby 
$_SERVER['QUERY_STRING'];

$set '';
if (
$sortby == '') {
    
$sortby 'field3';
    
$set 'y';
}
if (
$sortby == 'field3') {
    
$set 'y';
}
if (
$set == '') {
    echo 
'The variable at the end of the web address did not match one required by the code. Please check the web address for errors.';
    exit;
}
 
$number 0;
$fp fopen('data.txt','r');
if (!
$fp) {echo 'ERROR: Unable to open file.'; exit;}

while (!
feof($fp)) {
    
$line fgets($fp,1024); //use 2048 if very long lines
    
$row++;
 list (
$field1$field2$field3$field4) = split ('\|'$line);
    if (
$sortby == 'field3'$sortkey strtolower($field3);
    
$col[$row] = array($sortkey$field1$field2$field3$field4);
}

fclose($fp);

sort($col);
reset ($col);

$arrays count($col) - 1;

$loop = -1;
while (
$loop $arrays) {
    
$loop++;
       
$number++;
    echo 
'
<td class="td"><div align="center"><a href="'
.$col[$loop][1].'">'.$col[$loop][2].'<br><img src="pets/'.$col[$loop][4].'.png" width="110" class="'.$col[$loop][3].'"></a></div></td>
'
;
   if((
$number 4)==0)
   {
    echo 
"</tr>";
    echo 
"<tr>";
   }
}
?>
field 3 is a number from 1 - 7.

How do I get all the 1's to show up on one page and all the 2's to show up on another, etc.
simster is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-08-2008, 03:08 AM Re: Pagination help?
Novice Talker

Posts: 6
Trades: 0
PHP Code:

<?php


function cmp($a$b)
{
    if (
$a[2] == $b[2]) {
        return 
0;
    }
    return (
$a[2] < $b[2]) ? -1;
}

$a[0] = array(32561);
$a[1] = array(35461);
$a[2] = array(31661);


usort($a"cmp");

foreach (
$a as $key => $value) {
    echo 
"\$key: $key\n";
    
var_dump($value)."\n";
}


?>
That sorts $a on the third element in the second dimension. I think that's what you need.

http://us.php.net/manual/en/function.usort.php

Last edited by LogicFlux; 05-08-2008 at 03:13 AM..
LogicFlux is offline
Reply With Quote
View Public Profile
 
Old 05-08-2008, 04:15 AM Re: Pagination help?
Extreme Talker

Posts: 189
Trades: 0
done code

after more than 20 minutes going through the code with my parents (both good SAS coders) I fixed the whole code.
simster is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Pagination help?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22290 seconds with 12 queries