1
I have a table, which shows all the data from 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 it doesn’t work. How can I present it in 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";
which errors php returns ?
– gmsantos
Do not sort me by name, I have well the order function to sort by ASC, and qd click on the hyperlink calls the function. I want you to change the table below
– akm
right, error in copying.
– akm
@akm, let me get this straight. You have an already populated table, and by clicking on a link, you want that table to be ordered. Check?
– Anthony Accioly
Exactly, I want it in order of name, and then by the other fields of the table.
– akm