le 19/06/2011 à 06:53
Papge par page Mysqli
Il manque un truc dans le page par page dans le tuto, c'est le précédent et suivant. Il y a bien << et >> mais pas < ni >. J'aimerais bien les ajouter. Merci.
<?php
$connexion = new mysqli('localhost', 'root', '');
$connexion->select_db('origami');
if (mysqli_connect_errno()) {
printf("Échec de la connexion : %s\n", mysqli_connect_error());
exit();
}
function Coupure($chaine,$max){
if(strlen($chaine)>=$max){$chaine=substr($chaine,0,$max) . "..." ;}
Return $chaine;
}
$resultat=$connexion->query("SELECT titre,menus FROM `origami`.`ori_menus` WHERE `id`=2");
while ($ligne = $resultat->fetch_object()){
echo '<div style="background-color:#C9D8B6;text-align:center;color:#ffffff;"><strong> '.$ligne->titre.'</strong></div>';
echo '<div style="background-color:transparent;text-align:center;color:#5F7939;margin:4px;"> '.$ligne->menus.'</div>';
}
$album=$connexion->query("SELECT * FROM `origami`.`ori_images`");
echo '<table width="100%" bgcolor="#93AC6F">';
while ($ligne = $album->fetch_object()){
echo '<tr>';
echo '<td width="10%" valign="top" bgcolor="#F7FAF3"><a href="admin/images/'.$ligne->images.'" target="_blank"><img src="admin/images/thumb_'.$ligne->images.'" width="90" height="90" border="0"></a></td>';
echo '<td width="*" valign="top" bgcolor="#F7FAF3"><div style="background-color:#5F7939;text-align:center;color:#E0F0C8"><strong> '.Coupure($ligne->titre,70).'</strong></div><br><div style="margin-left:6px;margin-right:6px;">'.Coupure($ligne->desc,333).'</div></td>';
echo '</tr>';
}
echo '</table>';
?>
<?php
$redirection = "jpg////";
echo $redirection.'<br />';
$redirection = preg_match('/[a-z]/', $redirection, $match);
if ($redirection == "1") {
print_r($match);
}
else {
print_r($match);
}
?>