
le 12/02/2005 à 15:04
session
bon voila j'ai fais un petit script c'est très basique mais j'ai testé il fonctionne
j'ai crée
ensuite 3 fichiers
ensuite
et finalement
et apres ben c'est le même principe pour avoir les infos du bouquins selectionné
j'ai crée
j'ai crée uen simple table
CREATE TABLE /*!32300 IF NOT EXISTS*/ livres (
id tinyint(3) unsigned NOT NULL auto_increment,
auteur varchar(50) NOT NULL DEFAULT '0' ,
livres varchar(50) NOT NULL DEFAULT '0' ,
PRIMARY KEY (id),
INDEX id (id)
);
ensuite 3 fichiers
index.php
<?php
echo'<html>
<head>
<title>bibliotheque</title>
</head>
<body>
Choisi ton auteur
<form method="POST" action="bouquins.php">
<select name="auteur">
<option>auteur 1</option>
<option>auteur 2</option>
<option>auteur 3</option>
</select>
<br>
<input type="submit" value="Envoyer">
</form>
</body>
</html>';
?>
ensuite
connect.php
<?php
$dbname ='biblio';
$hostname='localhost';
$username='root';
$password='ton pass';
$id_link =mysql_connect("$hostname",$username,$password);
mysql_select_db ('biblio', $id_link);
?>
et finalement
bouquins.php
<?php
include "connect.php";
//requete
echo'<u>auteur</u><br>';
echo $_POST['auteur'];
$sql ='SELECT livres from livres where auteur ="'.$_POST['auteur'].'"';
$req=mysql_query($sql)or die('erreur sql!<br>'.$sql.'<br>'.mysql_error());
//affichage du menu deroulant
echo'<form method="POST" action="resultats.php">';
echo'<select name="livres">';
while ( $data = mysql_fetch_array($req))
{
$livres=$data['livres'];
echo' <option>';
echo $livres;
echo'<br>';
echo' </option>';
}
echo'<input type="submit" value="voir les infos">';
echo'</form>';
mysql_close();
?>
et apres ben c'est le même principe pour avoir les infos du bouquins selectionné