fomalhaut
Member
- Messages
- 107
- Reaction score
- 0
- Points
- 16
Hello.
I've a html table with five column:
and I want the final user to be able to sort this table on the first or the second column, as he want.
Data are taken from mySql database:
the JavaScript function recall() just call again the same page:
The recall() function works correctly, but the $_SESSION['tri'] is already set to the 'titre' value (in fact to the latest value written).
I don't understand why. Perhaps is there a simpler manner to do that ?
Thanks for advance for your help.
I've a html table with five column:
HTML:
<table style="text-align:center; border-color:blue" border='1' >
<caption><b>Liste des chants</b></caption>
<tr>
<th class="tri" onclick="<?php $_SESSION['tri']='cote_classement'; ?>; recall()" >Côte</th>
<th class="tri" onclick="<?php $_SESSION['tri']='titre'; ?>; recall()" >Titre</th>
<th>Auteur(s)</th>
<th>Compositeurs(s)</th>
<th>Livret</th>
</tr>
Data are taken from mySql database:
PHP:
<?php session_start(); // liste des chants (tables chants_t1 de jyc_applications)
if (!isset($_SESSION['tri'])) {$tri = 'cote_classement';}
else {$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>';
}
?>
Code:
function recall(loc) {
if (window.location.hostname == 'localhost') {window.location = "http://localhost/fomalhaut/menus/visuChants.php";}
else {window.location = "http://" + window.location.hostname + "/menus/visuChants.php";}
}
I don't understand why. Perhaps is there a simpler manner to do that ?
Thanks for advance for your help.