RE: [PHP] maximum time
| From: | Cesare D'Amico | Date: | Wed, 19 Jul 2000 17:59:00 +0000 |
| Subject: | RE: [PHP] maximum time | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-7309@lists.php.net to get a copy of this message | ||
> "Fatal error: Maximum execution time exceeded "
> What's the way to fight this? I wanted to ask a couple of more
> things:
there's a directive to put in the php3.ini file... can't remember now
what it is, check the manual... ;)
> Say I have 1000 entries in a database, and I want to list those
> entries with "Kathmandu" under the "place" field 10 on each
> page, and
> lets say there are 160 of those. Is there anyway I can do that so
that
> the first 10 is on the first page, the second 10 on the second...
> etc... What I'm doing right now is retrieving everything, but listing
> only 10 on each page, but I want to do is retrieve only 10.
Well, if I've understood what you request =) I make it this way:
BEFORE showing the table with your records, write something
lake this:
// $conn is the link identifier to the MySQL server
if( !isset($row) || $row == "" )
$row = 0; // number of the first row to show
if( $row < 0 )
$row = 0;
if( !isset($rxp) || $rxp == "" )
$rxp = 10; // rows to shwo in each page
$sql = "SELECT * FROM <table_name>";
$result = mysql_query($sql, $conn);
$numrows = mysql_num_rows($result);
$numpages = floor( ($numrows - 1) / $rxp + 1 );
// now you know how many records you have and the number of
// pages you'll need to show them
$sql .= " LIMIT $row, $rxp";
$result = mysql_query($sql, $conn);
// so the query gives you only $rxp records
// every time you perform it
....
now you show your records
....
// Now put a link to the previous and next pages...
echo "<a href=\"$PHP_SELF?row=".($row-$rxp)."&rxp=$rxp\">".
"<<< indietro</a>";
echo "<a href=\"$PHP_SELF?row=".($row+$rxp)."&rxp=$rxp\">".
"avanti >>></a>";
Use this code as you like, if you can't understand let me know...
Ciao
Cesare