1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| <?php
class req{
function connect( $host,$account,$password,$dbname ){
$this->dbname=$dbname;
$this->link = mysql_connect($host,$account,$password);
return mysql_select_db($dbname,$this->link);
}
function query_lim( $sql_1,$lim,$nbre ){
$this->sql_1=$sql_1;
$this->lim=$lim;
$this->nbre=$nbre;
$sql="SELECT * FROM ".$sql_1." LIMIT $lim,$nbre";
$this->answer = mysql_query($sql,$this->link);
return $this->answer;
}
function query( $sql ){
$this->answer = mysql_query($sql,$this->link);
return $this->answer;
}
function fetch_array(){
return mysql_fetch_array($this->answer);
}
function liens($page){
$limitesuivante = $this->lim + $this->nbre;
$limiteprecedente = $this->lim - $this->nbre;
$limitepg = $this->nbre - 1;
$select = "SELECT count(id) FROM ".$this->sql_1;
$result = mysql_query($select,$this->link) or die ('Erreur2 : '.mysql_error() );
$row = mysql_fetch_row($result);
$total = $row[0];
if($this->lim > $limitepg) {
echo '<a href="'.$page.'limite='.$limiteprecedente.'">page precedente</a>';
}
if($limitesuivante < $total && $this->lim > 0) {
echo'-';
}
if($limitesuivante < $total) {
echo '<a href="'.$page.'limite='.$limitesuivante.'">page suivante</a>';
}
}
}
?> |