I have a table, which shows all data in the SQLite database. I wanted to sort by name all the data and present them. I have a hyperlink that calls a function to sort. The problem is that it does not work. How can I make it to the table, on the same page.
$base_hndl = new SQLite3($dir.$base);
$requete = "SELECT * FROM contact ORDER BY id desc";
$resultat = $base_hndl->query($requete); //
$affiche = $resultat->fetchArray();//
$nombreid = $affiche['id'];
function order($base, $dir,$lib_module,$nombreid){
for($i=1;$i<=$nombreid;$i++)
{
$base_hndl = new SQLite3($dir.$base);
$requete = "SELECT prenom FROM $lib_module ORDER BY prenom ASC ";
$resultat = $base_hndl->query($requete); //
$affiche = $resultat->fetchArray();//
echo $affiche['prenom'];
}
}
if (isset($_GET['ordername'])) {
order($base,$dir,$lib_module,$nombreid);
}
And here the table, sorted by ID.
echo "<table border=0>\n";
echo "<tr align=center>\n";
echo "<td>ID</td>\n";
echo "<td><a href=?ordername=true>Nome</a></td>\n";
echo "<td>Ultimo Nome</td>\n";
echo "<td></td>\n";
for($i=1;$i<=$nombreid;$i++)
{
$requete = "SELECT * FROM contact WHERE (id=$i)";
$resultat = $base_hndl->query($requete); //
$affiche = $resultat->fetchArray();// tableau 'affiche'
if($affiche['id']!=0)
{
//write data
echo "<tr class=event bgcolor=$couleur align=left style='font-size:12px;font-family:helvetica'>\n";
echo "<td title=\"$lib_id\"><a href=_compil_vcf.php?id=$affiche[id]>$affiche[id]</a></td>\n";
echo "<td >$affiche[nom]</td>\n";
echo "<td >$affiche[prenom]</td>\n";
echo "<td >$affiche[fonction]</td>\n";
title=\"$clic_for_mail\" >$affiche[mail]</a></td>\n";
echo "</tr>\n";
}
}//fin de for
echo "</table>\n";