par
le_luke » 08 mars 2006, 12:14
Bonjour,
Je voudrais savoir comment faire pour relcasser les résultats obtenus après un QUERY....
De base le classement se fait par id mais je voudrais que quand on click sur "titre", le classement change par titre et plus par id.
Seulement voilà, évidemment ca ne marche pas....(le re-classement ne se fait pas)
voilà mon script:
<?php
$default_sort = 'id';
$allowed_order = array ('id','titre','realisateur','genre');
$order = $default_sort;
mysql_select_db($database_dvdtheque, $dvdtheque);
$query_dvdtheque = "SELECT * FROM dvdtheque ORDER BY $order ASC";
$dvdtheque = mysql_query($query_dvdtheque, $dvdtheque) or die(mysql_error());
$row_dvdtheque = mysql_fetch_assoc($dvdtheque);
$totalRows_dvdtheque = mysql_num_rows($dvdtheque);
?><!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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<p> </p>
<table width="813" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#CCCCCC"><a href="consult.php?order=titre">titre</a></td>
<td bgcolor="#CCCCCC"><a href="consult.php?order=real">realisateur</a></td>
<td bgcolor="#CCCCCC"><a href="consult.php?order=genre">genre</a></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_dvdtheque['titre']; ?></td>
<td><?php echo $row_dvdtheque['realisateur']; ?></td>
<td><?php echo $row_dvdtheque['genre']; ?></td>
</tr>
<?php } while ($row_dvdtheque = mysql_fetch_assoc($dvdtheque)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($dvdtheque);
?>
Bonjour,
Je voudrais savoir comment faire pour relcasser les résultats obtenus après un QUERY....
De base le classement se fait par id mais je voudrais que quand on click sur "titre", le classement change par titre et plus par id.
Seulement voilà, évidemment ca ne marche pas....(le re-classement ne se fait pas)
voilà mon script:
[php]<?php
$default_sort = 'id';
$allowed_order = array ('id','titre','realisateur','genre');
$order = $default_sort;
mysql_select_db($database_dvdtheque, $dvdtheque);
$query_dvdtheque = "SELECT * FROM dvdtheque ORDER BY $order ASC";
$dvdtheque = mysql_query($query_dvdtheque, $dvdtheque) or die(mysql_error());
$row_dvdtheque = mysql_fetch_assoc($dvdtheque);
$totalRows_dvdtheque = mysql_num_rows($dvdtheque);
?><!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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<p> </p>
<table width="813" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#CCCCCC"><a href="consult.php?order=titre">titre</a></td>
<td bgcolor="#CCCCCC"><a href="consult.php?order=real">realisateur</a></td>
<td bgcolor="#CCCCCC"><a href="consult.php?order=genre">genre</a></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_dvdtheque['titre']; ?></td>
<td><?php echo $row_dvdtheque['realisateur']; ?></td>
<td><?php echo $row_dvdtheque['genre']; ?></td>
</tr>
<?php } while ($row_dvdtheque = mysql_fetch_assoc($dvdtheque)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($dvdtheque);
?>[/php]