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
| <?php
//connection-----------------
mysql_connect("localhost","david","mornay");
mysql_select_db("cinemofil");
?>
<?php
//Alphabet--------------------
$alphabet = array('0-9');
for($i="A"; $i!='AA'; $i++){
$alphabet[ ] = $i;
}
?>
<div id="contenu">
<?php
if(isset($_GET['tri']) AND in_array($_GET['tri'], $alphabet))
{
$tri = $_GET['tri'];
$tri =='0-9' ? $where = "REGEXP '^([0-9]+)'" : $where = "LIKE' $tri%'";
$req = ("SELECT id, titre, genre FROM film WHERE titre LIKE '$tri%'");
$result=mysql_query($req);
$NbCol=3;
$NbToto=mysql_num_rows($result);
$NbLigne=1+(int)($NbToto/$NbCol);
$Lig=0;
while($dat = mysql_fetch_array($result))
{
echo '<a href="filmfiche.php?id='.$dat['id'].'">'. $dat['titre'].'</a>';
echo $dat['genre'];
echo '<br />';
$Lig=$Lig+1;
if($Lig==$NbLigne){
echo"<td>";$Lig=0;}
}
}
if (!empty($req)){
echo"pas de résultat";
}
else{
foreach($alphabet as $list)
{
echo '<a href="listing_films.php?tri='.$list.'"> '. $list.'</a>';
}
}
echo"</td></tr></table>";
?> |
Partager