sammy
08-08-2006, 07:30 PM
I'm having problems adding pagination and export to my website. Each of my pages will display 60 rows from my database in two tables (30 rows per table) by using limits. I would like to create an export to text file for each page which combines both tables (so all 60 rows per page) and only of the first two columns (item1+item2). My database will have a few thousands entries so I need to also add pagination...however I'm having issues doing this because I am using two tables per page with limits..I'm attaching a bit of code which consists of three files:
MAIN.PHP:
<?php
include ("mysql.php");
$result = mysql_query("SELECT * FROM TEST$$$$ Limit 0,30")or die(mysql_error());
include ("grid.php");
include ("ads.php");
$result = mysql_query("SELECT * FROM TEST$$$$ Limit 30,30")or die(mysql_error());
include ("grid.php");
include ("ads.php");
?>
MYSQL.PHP:
<?
mysql_connect("localhost", "user", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
?>
GRID.PHP:
<link rel="stylesheet" type="text/css" href="grid.css" />
<?
$aStyle = array("background-color:#FFFFFF ", "background-color:#00FF66 ");
$iStyle = 0;
echo "<table summary='testtable'>";
echo "<thead>";
echo "<tr> <th scope 'col'>item1</th> <th scope 'col'>item2</th> <th scope 'col'>item3</th> <th scope 'col'>item4</th> </tr>";
echo "</thead>";
while ($row = mysql_fetch_array($result)) {
echo "<tbody bgcolor='#FFCC66'>";
echo "<tr style=\"".$aStyle[++$iStyle%2]."\"><td id='item1'>";
echo $row['item1'];
echo "</td><td>";
echo $row['item2'];
echo "</td><td>";
echo date('F d, Y ');
echo "</td><td id='item4'>";
echo "<span class='sp_link'>item4</span>";
echo "</td></tr>";
echo "</tbody>";
}
echo "</table>";
?>
MAIN.PHP:
<?php
include ("mysql.php");
$result = mysql_query("SELECT * FROM TEST$$$$ Limit 0,30")or die(mysql_error());
include ("grid.php");
include ("ads.php");
$result = mysql_query("SELECT * FROM TEST$$$$ Limit 30,30")or die(mysql_error());
include ("grid.php");
include ("ads.php");
?>
MYSQL.PHP:
<?
mysql_connect("localhost", "user", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
?>
GRID.PHP:
<link rel="stylesheet" type="text/css" href="grid.css" />
<?
$aStyle = array("background-color:#FFFFFF ", "background-color:#00FF66 ");
$iStyle = 0;
echo "<table summary='testtable'>";
echo "<thead>";
echo "<tr> <th scope 'col'>item1</th> <th scope 'col'>item2</th> <th scope 'col'>item3</th> <th scope 'col'>item4</th> </tr>";
echo "</thead>";
while ($row = mysql_fetch_array($result)) {
echo "<tbody bgcolor='#FFCC66'>";
echo "<tr style=\"".$aStyle[++$iStyle%2]."\"><td id='item1'>";
echo $row['item1'];
echo "</td><td>";
echo $row['item2'];
echo "</td><td>";
echo date('F d, Y ');
echo "</td><td id='item4'>";
echo "<span class='sp_link'>item4</span>";
echo "</td></tr>";
echo "</tbody>";
}
echo "</table>";
?>