
Originally Posted by
Deviante
Sorry for my poor english, i'm spanish.
Do not apologize, Deviante, mine is not better: I'm french !
I hav'not understand the javascript side. That are my modifications :
HTML Code:
<table style="text-align:center; border-color:blue" border='1' >
<caption><b>Liste des chants</b></caption>
<tr>
<th class="tri" onclick="recall('cote_classement')" >Côte</th>
<th class="tri" onclick="recall('titre')" >Titre</th>
<th>Auteur(s)</th>
<th>Compositeurs(s)</th>
<th>Livret</th>
</tr>
PHP Code:
<?php session_start(); // liste des chants (tables chants_t1 de jyc_applications)
if (isset($_GET['sort'])) {$_SESSION['tri'] = $_GET['sort']; }
else {$_SESSION['tri'] = 'cote_classement';}
$tri = $_SESSION['tri'];
echo 'tri sur //'.$tri.'//';
$sqlChants = "SELECT * FROM jyc_applications.chants_t1 order by " . $tri;
$resChants = $dbh->query($sqlChants);
foreach ($resChants as $ligne) {
echo '<tr style="color:red; text-indent:5; text-align:left"><td><b>'.$ligne['cote_reelle'].'</b></td>
<td style="color:blue">'.noQuote($ligne['titre']).'</td>
<td style="color:green">'.noQuote($ligne['auteur']).'</td>
<td style="color:green">'.noQuote($ligne['compositeur']).'</td><td>'.$ligne['livret'].'</td></tr>';
}
?>
javascript:
Code:
function recall(tri) {
"&sort="+tri;
if (window.location.hostname == 'localhost') {window.location = "http://localhost/fomalhaut/menus/visuChants.php";}
else {window.location = "http://" + window.location.hostname + "/menus/visuChants.php";}
}
And this time, the table is already sorted on the first column (cote_classement) ! as if teh $_GET was not set !
thanks telling me where I'm wrong ?