1
I want to show by afabetica the contents of a column of a table cm SQL. For example I tried this but only return me two record, while I have much more, the nombreid contains the COUNT of the database.
$y='a';
//for table users
for($i=1;$i<=$nombreid;$i++)
{
$requete = "SELECT * FROM contact WHERE (id=$i) AND nom LIKE '$y%'";
$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 title=\"$lib_nom\">$affiche[nom]</td>\n";
echo "<td title=\"$lib_prenom\">$affiche[prenom]</td>\n";
echo "<td title=\"$lib_fonction\">$affiche[fonction]</td>\n";
echo "<td title=\"$lib_societe\">$affiche[societe]</td>\n";
echo "<td title=\"$lib_mobile\">$affiche[mobile]</td>\n";
echo "<td title=\"$lib_mail\"><a href=mailto:$affiche[mail] title=\"$clic_for_mail\" >$affiche[mail]</a></td>\n";
echo "</tr>\n";
$couleur = get_couleur_fond($couleur,$couleur1,$couleur2);// change de couleur de fond
$y++;
}
I already try to order with the
ORDER BY
?– MeuChapeu
Yes I experimented with ORDER BY prenom, but always show me the order by ID.
– akm
$requete="SELECT * FROM contact WHERE (id=$i) ORDER BY 'prenom'";
– akm