PHP Classes
elePHPant
Icontem

File: ex.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Islam Ahmed Kandel  >  Split SQL Selected results  >  ex.php  >  Download  
File: ex.php
Role: Example script
Content type: text/plain
Description: Example
Class: Split SQL Selected results
Split MySQL query results in multiple pages
Author: By
Last change: Example
Date: 7 years ago
Size: 1,385 bytes
 

Contents

Class file image Download
<?php

/**
 * @author PHP&MYSQL PrOgRAmMeR EsLAm AhMeD KaNDeL
 * @copyright 2008
 * @email science20012003@hotmail.com
 * @creat time: 3:53 Date 25-6-2008
 */
require_once 'spilt_sql_result.class.php';
/* Connecting, selecting database */
$db_link = mysql_connect("localhost", "root", "123456");
if (!
$db_link) {
    die(
"Could not connect: " . mysql_error());
}
mysql_select_db("test_db") or die("Could not select database");

/* Performing SQL query */
$split = new page_spilt("SELECT * FROM `test_table`", $_GET["p"]);
$rs = $split->get_results();
if (
is_array($rs)) {
    foreach (
$rs as $key => $value) {
        echo
$rs[$key][0] . " " . $rs[$key][1] . " " . $rs[$key][2] . "<br>";
    }
   
//$split->querystring="r=2&d=3"; Just example
   
$rs = $split->get_numbers(); // &#1610;&#1605;&#1603;&#1606; &#1608;&#1590;&#1593; &#1575;&#1604;&#1575;&#1585;&#1602;&#1575;&#1605; &#1601;&#1609; &#1602;&#1575;&#1574;&#1605;&#1577; &#1605;&#1606;&#1587;&#1583;&#1604;&#1577;
   
foreach ($rs as $key => $value) {
        if (empty(
$value))
            echo
$key . "&nbsp;&nbsp;";
        else
            echo
"<a href=\"$value\">$key</a>&nbsp;&nbsp;";
    }
    echo
"<br />results from ".$split->rsfrom." to ".$split->rsto." Total:".$split->totalresnumber;
} else {
    echo
"No result";
}
/* Closing connection */
mysql_close($db_link);


?>