logo   Home Download Documentation Support

 

DashingDB Documentation

Learn to use DashingDB Within Minutes

 

Show Results in Multiple Pages Example

This example do the concept of pagination which means all results are divided in specific pages.

Examples

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pagination Example</title>


<style type="text/css">
h1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 36px;
font-weight: normal;
color: #FFFFFF;
}
.nText {
font-family: Tahoma, Geneva, sans-serif;
font-size: 14px;
font-weight: normal;
color: #000;
}
.eText {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
color: #666;
}
.oText {
font-family: Tahoma, Geneva, sans-serif;
font-size: 16px;
font-weight: normal;
color: #03C;
line-height: 30px;
}
.tblHead {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color: #CCC;
}
.pagesLink {
font-family: Tahoma, Geneva, sans-serif;
font-size: 14px;
font-weight: normal;
color: #930;
}
.pagesText {
font-family: Tahoma, Geneva, sans-serif;
font-size: 14px;
font-weight: bold;
color: #333;
padding-right: 50px;
padding-left: 50px;
}
</style>
</head>

 

<body>


<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="50" align="center" bgcolor="#FD3E27"><h1>Pagination Example</h1></td>
</tr>
</table>


<p class="nText">This example shows you example of pagination.</p>
<p class="eText">Following is the output of current example:</p>


<?php
include("class.php");

$condition["field_1"]["neq"] = "";

if (!isset($_REQUEST["p"]))
{
$split["page"] = 1;
}
else
{
$split["page"] = $_REQUEST["p"];
}

$split["rpg"] = 3;

$total_pages = mysql_split_total_pages("table_name_1", $condition, $split);
$data = mysql_show_row("table_name_1", $condition, $split, "false");

$text = "";
foreach($data as $value)
{
$text .= '<tr>
<td height="40" align="center" bgcolor="#CCCCCC" class="nText">'.$value["field_1"].'</td>
<td align="center" bgcolor="#CCCCCC"><span class="nText">'.$value["field_2"].'</span></td>
</tr>';
}
?>


<p><a href="?p=<?php echo $split["page"]-1; ?>"><span class="pagesLink">Previus Page</span></a> <span class="pagesText">Page <?php echo $split["page"]; ?> of <?php echo $total_pages; ?></span> <a href="?p=<?php echo $split["page"]+1; ?>"><span class="pagesLink">Next Page</span></a></p>


<table width="50%" border="0">
<tr>
<td align="center" bgcolor="#333333" class="tblHead">field_1</td>
<td align="center" bgcolor="#333333" class="tblHead">field_2</td>
</tr>
<?php echo $text; ?>
</table>


<p>&nbsp;</p>


</body>


</html>

 

 

 

© 2017 DashingDB.