[gull] Questions sur requête SQL intégrée dans php
Rafael Muñoz Moreno-Davila
rmmd at t-d-e.org
Wed Apr 12 22:52:38 CEST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
J'aimerais capturer une colonne en entier dans ma base mysql, et ensuite
pouvoir y naviguer en changeant juste le numero entre [].
Jusqu'a maintenant je n'ai réussi qu'a avoir la première ligne
uniquement de ma bd.
L'idée est la suivante: faire un systeme de note par page, en affichant
une ou plusieurs image selon la note ex: note 4, 4 images (comme un 4
etoiles quoi), et donc faire ça pour toutes les pages du site, on peut
aussi voter et donc changer la note.
Merci pour votre aide.
Voici mon code:
<?
include "inc/config.inc.php";
$table="Rated";
// connect to mysql server
$connection = mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db,$connection) or die(mysql_error());
// build the query
$query = "SELECT note FROM $table";
// store the result
$result = mysql_query($query, $connection) or die(mysql_error());
// fetch first row of the result in a hash (otherwise use mysql_fetch_row
// if you want an array (see below)
$value = mysql_fetch_array($result) or die(mysql_error());
mysql_close($connection);
for ($i = 1;$i <= $value[0];$i += 1)
{
echo "<img src=\"Global_images/dolphin.png\" alt=\"Title\"
height=\"18\" width=\"23\">";
}
echo $value[0];
$page = $_SERVER['PHP_SELF'];
echo "</p>";
echo "<p>Rate this page:";
echo "<form method=\"post\" action=\"vote.inc.php\">";
echo "<input name=\"Rate\" value=\"\" type=\"text\">";
echo "<input name=\"Page\" value=\"$page\" type=\"hidden\">";
echo "<input name=\"validate\" value=\"Validate\" type=\"submit\">";
echo "</p>";
?>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEPWiWtsFe7lci6uIRAluEAJ0X2KL5mii3fSZP+SIR/hCYHP7H9QCfcEQH
fHplRoRxgspOhxcbZphUgxs=
=wGon
-----END PGP SIGNATURE-----
More information about the gull
mailing list