1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
<?php
$hostname = "_____";
$database = "____";
$username = "____";
$password = "____";
$connexion = mysql_connect($hostname, $username, $password);
$selection_de_la_base = mysql_select_db($database,$connexion);
print ();
/* Affiche la liste des catégories */
function ()
{
/* Initialisation des variables et constantes */
$requete = "SELECT id_article, designation, prix_unitaire FROM articles";
$qid = mysql_query($requete) or DIE('Une erreur de connexion à la base s est produite ' .MYSQL_ERROR());
$j = 0;
if (mysql_num_rows($qid) > 0)
{
$nb_cellules = mysql_num_rows($qid);
$nb_colonnes = 4;
}
}
?>
<table align="center" border="2" cellspacing="1" cellpadding="1" width="100%">
<tr><td colspan="<?php echo $nb_colonnes?>">Nos produits</td></tr>
<?php
while ($cat = mysql_fetch_array($qid))
{
if ($j % $nb_colonnes == 0)
{
echo "<tr valign=\"top\">";
}
if($j % $nb_colonnes !=0 OR $j % $nb_colonnes == 0 )
{
// on affiche une cellule
echo "<td class=\"petit\" width=\"50%\">";
}
}
?>
<table align="center" border="0" cellspacing="0" cellpadding="0" width="100%">
<tr><td align="center"><?php echo $cat['nom']?></td></tr>
</table>
<?php
echo "</td>";
$j++;
if ($j % $nb_colonnes == 0 OR $j == $nb_cellules)
{
echo "</tr>";
}
?>
</table> |
Partager