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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
| <?php
/* Program: ShowPets.php
* Desc: Displays all the pets in a category. Category
* is passed in a variable from a form. The
* information for each pet is displayed on a
* single line, unless the pet comes in more than
* one color. If the pet comes in colors, a single
* line is displayed without a picture and a line
* for each color, with pictures, is displayed
* following the single line. Small pictures are
* displayed, which are links to larger pictures.
*/
?>
<html>
<head>
<title>Catalogue d'animaux</title>
</head>
<body topmargin="0" marginheight="0">
<?php
include("misc.php");
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
/* Slectionner un animal d'un certain type*/
$query = "SELECT * FROM Animal
WHERE animalType=\"{$_POST['interet']}\""; #27
$result = mysql_query($query)
or die ("Couldn't execute query.");
/* Affiche les résultats dans un tableau */
echo "<table cellspacing='10' border='0' cellpadding='0'
width='100%'>";
echo "<tr><td colspan='5' align='right'>
Cliquer sur l'image pour l'afficher en grand.<br><hr>
</td></tr>\n";
while ($ligne = mysql_fetch_array($result,MYSQL_ASSOC)) #38
{
$f_price = number_format($ligne['animalPrix'],2);
/* Y'a t'il plusieurs couleurs? */
$query = "SELECT * FROM Couleur
WHERE animalNom='{$ligne['animalNom']}'"; #44
$result2 = mysql_query($query) or die(mysql_error()); #45
$ncolors = mysql_num_rows($result2); #46
/* Affiche une ligne pour chaque animal */
echo "<tr>\n";
echo "<td>{$ligne['animalID']}</td>\n";
echo "<td><font size='+1'>
<b>{$ligne['animalNom']}</b></font></td>\n";
echo "<td>{$ligne['animalDescription']}</td>\n";
/* Affiche l'image de l'animal s'il n'y a pas plusieurs couleurs */
if ( $ncolors <= 1 ) #55
{
echo "<td><a href='../images/{$ligne['animalImage']}'
border='0'>
<img src='../images/{$ligne['animalImage']}' border='0'
width='100' height='80'></a></td>\n";
}
echo "<td align='center'>\$$f_price</td>\n
</tr>\n";
/* Afficher une ligne par couleur si plusieurs couleur */
if ($ncolors > 1 ) #65
{
while($ligne2 = mysql_fetch_array($result2,MYSQL_ASSOC))
{
echo "<tr><td colspan=2> </td>
<td>{$ligne2['animalcouleur']}</td>
<td><a href='../images/{$ligne2['animalImage']}'
border='0'>
<img src='../images/{$ligne2['animalImage']}' border='0'
width='100' height='80'></a></td>\n";
}
}
echo "<tr><td colspan='5'><hr></td></tr>\n";
}
echo "</table>\n";
echo "<div align='center'>
<a href='catalogue.php'>
<b>Voir d'autres animaux</b></a></div>";
?>
</body>
</html> |
Partager