*****************************************************
"Votre premire base de donnes avec MySQL"
Jean ENGELS 
Osman Eyrolles Multimdia
**************************************************************


Vous trouverez ci-dessous l'ensemble des fichiers PHP utiliss 
dans le livre "Votre premire base de donnes avec MySQL"

*  Chaque fichier porte le nom de la page dans laquelle il 
se trouve, pour permettre un reprage plus facile. Les 
fichiers qui portent dj un nom explicite dans le livre 
le conservent.

*  N'oubliez pas  d'adapter le nom du serveur("localhost" 
dans les exemples), le login("root" dans les exemples)  
de votre site et votre mot de passe ("" dans les 
exemples)  chaque fois qu'il est ncessaire.

*  Un copier-coller dans l'diteur PHPEditor3 (sur le CD-ROM 
d'accompagnement) vous permettra de tester ces scripts 
immdiatement (si vous avez install EasyPHP auparavant 
bien sr)

Vous pouvez tester les exemples du livre en ligne dans des 
conditions relles, en particulier le site "livres" et le site 
de petites annonces  l'adresse:

http://www.funprog.com/mysql/


page16.php3

<?php
echo "<b> Cration dynamique de tableau</b>";
$tab= array("PHP 4", "MySQL", "JavaScript", "Perl");
echo " <table width=300 border =\"2\"> ";
for ($i=0;$i<count($tab);++$i)
{
echo " <tr > ";
echo " <td width=100 > Ligne $i </td> ";
echo " <td> Livre $i = ".$tab[$i]." </td> ";
echo " </tr> ";
}
echo " </table>";
?>



page17.php3

<?php
echo "<b> Cration dynamique de tableau</b>";
$tab= array("un"=>"PHP 4","deux"=> "MySQL","trois"=>
"JavaScript","quatre"=> "Perl");
echo " <table width=300 border =\"2\"> ";
while($ligne=key($tab))
{
echo " <tr > ";
echo " <td width=100 > Ligne $ligne </td> ";
echo " <td> Livre $ligne = ".$tab[$ligne]." </td> ";
echo " </tr> ";
next($tab);
}
echo " </table>";
?>



page18.php3

<?php
echo "<b> Fonction list <br/></b>";
$tab= array(" MySQL "," PHP 4 ");
list($val1,$val2)=$tab;
echo "lment1 = ",$val1," lment2 = ",$val2,"<br />";
?>




page19.php3

<?php
echo "<b> Lecture d'un tableau<br/></b>";
$tab= array("un"=>"PHP 4","deux"=> "MySQL","trois"=>
"JavaScript","quatre"=> "Perl");
while(list($cle,$valeur)=each($tab))
{
echo "cl= ",$cle," valeur = ",$valeur,"<br />";
}
?>




page20.php3

<?php
echo "<b> Lecture d'un tableau<br/></b>";
$tab= array("PHP 4","MySQL", "JavaScript", "Perl");
$i=0;
foreach($tab as $valeur)
{
echo "indice= ",$i," valeur = ",$valeur,"<br />";
$i++;
}
?>




page21.php3

<?php
echo "<b> Lecture d'un tableau<br/></b>";
$tab= array("un"=>"PHP 4","deux"=> "MySQL","trois"=>
"JavaScript","quatre"=> "Perl");
foreach($tab as $cle=>$valeur)
{
echo "cl= ",$cle," valeur = ",$valeur,"<br />";
}
?>




page23.php3

<?php
echo "<b> if..elseif..else<br/></b>";
$age=6;
if($age<7){
echo "Trop jeune pour lire Tintin";}
elseif($age>77){
echo "Trop ag pour lire Tintin";}
else{echo "Vous pouvez lire Tintin";}
?>




page24.php3

<?php
$num="0680542218";
$reg = $num[1];//rcupre le deuxime chiffre
switch($reg)
{
case "1":
echo "Paris";
break;
case "2":
echo "Ouest";
break;
case "3":
echo "Nord";
break;
case "4":
echo "Sud-Est";
break;
case "5":
echo "Sud-Ouest";
break;
case "6":
echo "Portable";
break;
default:
echo "Il y a une erreur ou numros spciaux?";
break;
}
?>




page25.php3

<?php
$a=5;
$b=6;
$resultat = ($a==$b) ? "Egal": "Diffrent";
echo $resultat;//affiche : Diffrent
?>




saisie.php3

<html>
<head>
<title>Saisie de donnes </title>
</head>
<body>
<form method="post" action="result.php3">
<table width="330" border="1">
<tr>
<td width="115"><b>Nom</b</td>
<td width="205">
<input type="text" name="nom" size="40">
</td>
</tr>
<tr>
<td width="115 <b>Pr&eacute;nom</b></td>
<td width="205">
<input type="text" name="prenom" size="40"> </td>
</tr>
<tr>
<td width="115<b>Ville</b></td>
<td width="205">
<input type="text" name="ville1" size="40">
</td>
</tr>
<tr>
<td width="115"> <b>Abonn&eacute;</b></td>
<td width="205 "> Cochez cette case
<input type="checkbox" name="abonne" value="oui">
</td>
</tr>
<tr>
<td width="115">&nbsp;</td>
<td width="205">
<input type="submit" value="Envoyer" name = "submit">
</td>
</tr>
</table>
</form>
</body>
</html>




result.php3

<html>
<head>
<title>ACCUEIL </title>
</head>
<body>
<?php
echo "<h3>BONJOUR ",$prenom," ",$nom," vous habitez 
",$ville,"</h3>";
if($abonne=="oui")
echo "<b>En tant que membre, vous bnficiez d'une remise
10%</b>";
else
echo "<b>Devenez membre $nom !</b>";
?>
</body>
</html>




page43.php3

<html>
<body>
<h1>CREATION D'UNE BASE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
/*Cration avec une requte SQL de la base nomme"mabase2"
*/
$verif = mysql_query("CREATE DATABASE
mabase2",$id_connex);
if($verif)
{ echo "La base est cre";}
else {echo "Cration impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page45.php3

<html>
<body>
<h1>CREATION DE BASE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
/*Cration avec une requte SQL de la base nomme"mabase" */
$verif = mysql_create_db ("mabase3",$id_connex);
if($verif){ echo "La base est cre";}
else {echo "Cration impossible erreur N ", mysql_errno(),
mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>





page47.php3

<html>
<body>
<h1>SUPPRESSION D'UNE BASE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
/*Suppression avec une requte SQL de la base
nomme"mabase2" */
$verif = mysql_query("DROP DATABASE mabase2",$id_connex);
if($verif){ echo "La base est supprime";}
else {echo "Suppression impossible erreur N ",
mysql_errno(), mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page48.php3

<html>
<body>
<h1>SUPPRESSION D'UNE BASE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
/*Suppression avec une fonction MySQL de la base
nomme"mabase3" */
$verif = mysql_drop_db( "mabase3",$id_connex);
if($verif)
{ echo "La base est supprime";}
else {echo "Suppression impossible erreur N ",
mysql_errno(), mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page59.php3

<html>
<body>
<h1>CREATION D'UNE TABLE PAR UN SCRIPT </h1>
<?php
//connexion  la base
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
//slection de la base (facultatif en gnral)
mysql_select_db("monlogin",$id_connex);
/*Cration avec une requte SQL de la table
nomme"livres3" */
$requete="CREATE TABLE livres3
(isbn BIGINT (10) UNSIGNED NOT NULL ,
titre VARCHAR (50) NOT NULL ,
auteur VARCHAR (25) NOT NULL,
collec VARCHAR (20) DEFAULT 'Hors collection' NOT NULL,
paru DATE ,
PRIMARY KEY (isbn),
INDEX (titre))";
$verif = mysql_query("$requete",$id_connex);
if($verif)
{ echo "La table est cre";}
else {echo "Cration impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page60.php3

<html>
<body>
<h1>AJOUT D'UNE COLONNE DANS UNE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
/*Modification avec une requte SQL de la table
nomme"livres3" */
$requete="ALTER TABLE livres3 ADD image VARCHAR (9)
DEFAULT 'defau.gif',ADD UNIQUE (image)";
$verif = mysql_query("$requete",$id_connex);
if($verif)
{ echo "La colonne est cre";}
else {echo "Modification impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page61.php3

<html>
<body>
<h1>AJOUT D'UN INDEX DANS UNE TABLE </h1>
<?php
/connexion  la base
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
/*Modification avec une requte SQL de la table
nomme"livres" */
$requete="ALTER TABLE livres ADD INDEX(titre)";
$verif = mysql_query("$requete",$id_connex);
if($verif)
{ echo "L'index est cr";}
else {echo "Modification impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page62.php3

<html>
<body>
<h1>MODIFICATION DU TYPE D'UN CHAMP </h1>
<?php
$id_connex = mysql_connect (" localhost", " root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db(" monlogin",$id_connex);
//Modification du type avec une requte SQL
$requete="ALTER TABLE livres3 MODIFY titre TEXT NOT NULL";
$verif = mysql_query("$requete",$id_connex);
if($verif){ echo "Le type est modifi";}
else {echo "Modification impossible erreur N ",
mysql_errno(),mysql_error();}
//
mysql_close($id_connex);
?>
</body>
</html>




page63.php3

<html>
<body>
<h1>MODIFICATION DU TYPE D'UN CHAMP DANS UNE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
//Modifications avec une requte SQL
$requete1="ALTER TABLE livres3 ALTER collec DROP
DEFAULT";
$requete2="ALTER TABLE livres3 ALTER paru SET DEFAULT
'2000-01-01'";
$verif1 = mysql_query("$requete1",$id_connex);
$verif2 = mysql_query("$requete2",$id_connex);
if($verif1 && $verif2)
{ echo "Les modifications sont ralises";}
else {echo "Modifications impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page64.php3

<html>
<body>
<h1>MODIFICATION DU NOM D UN CHAMP DANS UNE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
//Modification du type avec une requte SQL
$requete="ALTER TABLE livres3 CHANGE isbn code INT(8)
UNSIGNED not null ";
$verif = mysql_query("$requete",$id_connex);
if($verif)
{ echo "Le champ est modifi";}
else {echo "Modification impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page65.php3

<html>
<body>
<h1>SUPPRESSION D'UN CHAMP DANS UNE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
//Suppression du champ avec une requte SQL
$requete="ALTER TABLE livres3 DROP image ";
$verif = mysql_query("$requete",$id_connex);
if($verif)
{ echo "Le champ est supprim";}
else {echo "Suppression impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page66.php3

<html>
<body>
<h1>RENOMMER UNE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
/*Renomme la table "livres3" en "livres4" avec une
requte SQL*/
$requete="ALTER TABLE livres3 RENAME livres4 ";
$verif = mysql_query("$requete",$id_connex);
if($verif)
{ echo "La table est renomme livres4";}
else {echo "Changement impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page68.php3

<html>
<body>
<h1>SUPPRIMER UNE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
//Supprime la table "livres3" avec une requte SQL
$requete="DROP TABLE IF EXISTS livres3 ";
$verif = mysql_query("$requete",$id_connex);
if($verif)
{ echo "La table livres3 est supprime ";}
else {echo "Suppression impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




droptable.php3

<html>
<body>
<h1>SUPPRIMER UNE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
//Supprime la table "livres3" avec une requte SQL
$requete="DROP TABLE IF EXISTS livres3 ";
$verif = mysql_query("$requete",$id_connex);
if($verif)
{ echo "La table livres3 est supprime ";}
else {echo "Suppression impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




livres.txt

"2746401266";"Votre premier programme en Visual
Basic";"Rmy LENTZNER";"Droit au But";"2000-02-03"
"2746402614";"PHP 4 Totale Initiation";"Tim CONVERSE et
Joyce PARK";"Rfrence";"2000-11-24"
"2746402522";"JavaScript Les rfrences du
programmeur";"Jean ENGELS";"Pro Micro";"2001-01-05"





page74.php3

<html>
<body>
<h1>INSERER DES DONNEES DANS UNE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
//les donnes sont dans le script
$isbn = "2746402017";
$titre ="Perl";
$auteur="Anne Bohy";
$collec="Mini Rfrence";
$paru= "2001-06-04";
$image="per01.gif";
//requte SQL
$requete="INSERT INTO livres
(isbn,titre,auteur,collec,paru,image)VALUES('$isbn','$tit
re','$auteur','$collec','$paru','$image')";
$verif = mysql_query($requete,$id_connex);
if($verif)
{ echo "L'insertion est russie";}
else {echo "Insertion impossible erreur N ",
mysql_errno(), mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page75.php3

<html>
<body>
<h1>INSERER DES DONNEES DANS UNE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
$isbn = "2746402629";
$titre ="HTML4 Web Fondamental";
$auteur="B Pfaffenberger et B Karrow";
$collec="La Rfrence";
$paru= "2000-12-21";
$image="htm01.gif";
$requete="INSERT INTO livres SET
isbn='$isbn',titre='$titre',auteur='$auteur',collec='$col
lec',paru='$paru',image='$image'";
$verif = mysql_query($requete,$id_connex);
if($verif)
{ echo "L'insertion est russie";}
else {echo "Insertion impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page76.php3

<html>
<body>
<h1>INSERER DES DONNEES A PARTIR D'UNE AUTRE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
$requete="INSERT INTO livres SELECT * FROM livresbis";
$verif = mysql_query($requete,$id_connex);
if($verif)
{ echo "L'insertion est russie";}
else {echo "Insertion impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page78 .php3

<html>
<body>
<h1>PROJECTION A PARTIR d'UNE AUTRE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
$requete="INSERT INTO auteurs(auteur) SELECT auteur FROM
livres";
$verif = mysql_query($requete,$id_connex);
if($verif)
{ echo "L'insertion est russie";}
else {echo "Insertion impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




forminsert.php3

<html>
<head>
<title>Formulaire d'insertion dans la table livres</
title>
</head>
<body bgcolor="#FFFFFF">
<p><b>Formulaire d'insertion de donn&eacute;es dans la
table &quot;livres&quot;:</b></p>
<form method="post" action=" stock.php3" name="form1">
<table width="50%" border="2" cellpadding="3">
<tr>
<td width="35%">Titre</td>
<td width="65%">
<input type="text" name="titre" size="50"
maxlength="50">
</td>
</tr>
<tr>
<td width="35%">Auteur</td>
<td width="65%">
<input type="text" name="auteur" maxlength="25"
size="25">
</td>
</tr>
<tr>
<td width="35%">Collection</td>
<td width="65%">
<input type="text" name="collec">
</td>
</tr>
<tr>
<td width="35%">Date</td>
<td width="65%">
<input type="text" name="paru" size="10"
maxlength="10"> format AAAA-MM-JJ </td>
</tr>
<tr>
<td width="35%">ISBN</td>
<td width="65%">
<input type="text" name="isbn maxlength="10"
size="10">
</td>
</tr>
<tr>
<td width="35%">Image gif</td>
<td width="65%">
<input type="text" name="image">
</td>
</tr>
<tr>
<td width="35%">
<input type="reset" name="effacer" value="Effacer"
>
</td>
<td width="65%">
<input type="submit" name="envoyer"
value="Envoyer">
</td>
</tr>
</table>
</form>
</body>
</html>




page79.php3

<html>
<head>
<title>Formulaire d'insertion dans la table livres</
title>
</head>
<body bgcolor="#FFFFFF">
<p><b>Formulaire d'insertion de donn&eacute;es dans la
table &quot;livres&quot;:</b></p>
<form method="post" action=" stock.php3" name="form1">
<table width="50%" border="2" cellpadding="3">
<tr>
<td width="35%">Titre</td>
<td width="65%">
<input type="text" name="titre" size="50"
maxlength="50">
</td>
</tr>
<tr>
<td width="35%">Auteur</td>
<td width="65%">
<input type="text" name="auteur" maxlength="25"
size="25">
</td>
</tr>
<tr>
<td width="35%">Collection</td>
<td width="65%">
<input type="text" name="collec">
</td>
</tr>
<tr>
<td width="35%">Date</td>
<td width="65%">
<input type="text" name="paru" size="10"
maxlength="10"> format AAAA-MM-JJ </td>
</tr>
<tr>
<td width="35%">ISBN</td>
<td width="65%">
<input type="text" name="isbn maxlength="10"
size="10">
</td>
</tr>
<tr>
<td width="35%">Image gif</td>
<td width="65%">
<input type="text" name="image">
</td>
</tr>
<tr>
<td width="35%">
<input type="reset" name="effacer" value="Effacer"
>
</td>
<td width="65%">
<input type="submit" name="envoyer"
value="Envoyer">
</td>
</tr>
</table>
</form>
</body>
</html>





stock.php3

<html>
<head><title> Formulaire et MySQL </title>
</head>
<body>
<h3>INSERTION A PARTIR D'UN FORMULAIRE </h3>
<?php
$id_connex=mysql_connect("localhost","root","") or
die("Connexion impossible");
mysql_select_db("monlogin",$id_connex);
$requete="INSERT INTO
livres(isbn,titre,auteur,collec,paru,image)
VALUES('$isbn','$titre','$auteur','$collec','$paru','$ima
ge')";
$verif = mysql_query($requete,$id_connex);
if($verif)
{ echo "L'insertion est russie<br />";
echo "Vous avez insr le livre: <br />";
echo "Titre:".$titre."<br /> de:".$auteur."<br />
collection:".$collec."<br /> paru le:".$paru."<br />
image:".$image."<br /> code: ".$isbn;}
else {echo "Insertion impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page81.php3

<html>
<head><title> Formulaire et MySQL </title>
</head>
<body>
<h3>INSERTION A PARTIR D'UN FORMULAIRE </h3>
<?php
$id_connex=mysql_connect("localhost","root","") or
die("Connexion impossible");
mysql_select_db("monlogin",$id_connex);
$requete="INSERT INTO
livres(isbn,titre,auteur,collec,paru,image)
VALUES('$isbn','$titre','$auteur','$collec','$paru','$ima
ge')";
$verif = mysql_query($requete,$id_connex);
if($verif)
{ echo "L'insertion est russie<br />";
echo "Vous avez insr le livre: <br />";
echo "Titre:".$titre."<br /> de:".$auteur."<br />
collection:".$collec."<br /> paru le:".$paru."<br />
image:".$image."<br /> code: ".$isbn;}
else {echo "Insertion impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page84.php3

<html>
<body>
<h1>SUPPRIMER DES DONNEES DANS UNE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
$requete="DELETE FROM livresbis WHERE auteur='Jean
Engels'";
$verif = mysql_query($requete,$id_connex);
if($verif)
{ echo "La suppression est russie";}
else {echo "Suppression impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page85.php3

<html>
<body>
<h1>MODIFIER DES DONNEES DANS UNE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
$requete="UPDATE livres SET paru='2000-07-23'WHERE
isbn='2746402017'";
$verif = mysql_query($requete,$id_connex);
if($verif)
{ echo "La modification est russie";}
else {echo "Modification impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




page86.php3

<html>
<body>
<h1>REMPLACER DES DONNEES DANS UNE TABLE </h1>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
$isbn = "2746403854";
$titre ="Votre premire base de donnes avec MySQL";
$auteur="Jean Engels";
$collec="Droit au But";
$paru= "2001-09-15";
$image="mys01.gif";
$requete="REPLACE INTO livres
(isbn,titre,auteur,collec,paru,image)VALUES('$isbn','$tit
re','$auteur','$collec','$paru','$image')";
$verif = mysql_query($requete,$id_connex);
if($verif)
{ echo "L'insertion est russie";}
else {echo "Insertion impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
</body>
</html>




stockreplace.php3

<?php
$id_connex=mysql_connect("localhost","root","") or
die("Connexion impossible");
mysql_select_db("monlogin",$id_connex);
$requete="REPLACE INTO livres
(isbn,titre,auteur,collec,paru,image)VALUES('$isbn','$tit
re','$auteur','$collec','$paru','$image')";
$verif = mysql_query($requete,$id_connex);
if($verif)
{ echo "L'insertion est russie<br />";
echo "Vous avez insr le livre: <br />";
echo "Titre:".$titre."<br /> de:".$auteur."<br />
collection:".$collec."<br /> paru le:".$paru."<br />
image:".$image."<br /> code: ".$isbn;}
else {echo "Insertion impossible erreur N ",
mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>




page92.php3

<html>
<body>
<h3>LECTURE DES DONNEES </h3>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_selectdb("monlogin",$id_connex);
//requete SQL
$id_result = mysql_query ("SELECT * FROM
livres",$id_connex);
if(!$id_result){ echo "Lecture impossible, erreur
N",mysql_errno(),mysql_error();}
//affichage du nombre de lignes
$nblignes= mysql_num_rows($id_result);
echo "Il y a ",$nblignes, " livres dans la slection <br/
>";
//affichage de tous les rsultats
while($tablivres =
mysql_fetch_array($id_result,MYSQL_ASSOC))
{
echo "<b> Titre : ",$tablivres['titre'],"<br/>";
echo "Auteur : ",$tablivres['auteur'],"<br/>";
echo " Collection : ",$tablivres['collec'],"<br/>";
echo "ISBN : ",$tablivres['isbn'],"<br/> ";
echo "Paru le : ",$tablivres['paru'],"<br/></b> <br/>";
}
mysql_close($id_connex);
?>
</body>
</html>




lecturearray.php3

<html>
<body>
<h3>LECTURE DES DONNEES </h3>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_selectdb("monlogin",$id_connex);
//requete SQL
$id_result = mysql_query ("SELECT * FROM
livres",$id_connex);
if(!$id_result){ echo "Lecture impossible, erreur
N",mysql_errno(),mysql_error();}
//affichage du nombre de lignes
$nblignes= mysql_num_rows($id_result);
echo "Il y a ",$nblignes, " livres dans la slection <br/
>";
//affichage de tous les rsultats
while($tablivres =
mysql_fetch_array($id_result,MYSQL_ASSOC))
{
echo "<b> Titre : ",$tablivres['titre'],"<br/>";
echo "Auteur : ",$tablivres['auteur'],"<br/>";
echo " Collection : ",$tablivres['collec'],"<br/>";
echo "ISBN : ",$tablivres['isbn'],"<br/> ";
echo "Paru le : ",$tablivres['paru'],"<br/></b> <br/>";
}
mysql_close($id_connex);
?>
</body>
</html>




lecturearray2.php3

<html>
<body>
<h3>LECTURE DES DONNEES </h3>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_selectdb("monlogin",$id_connex);
/*Cration avec une requte SQL de la base nomme"mabase"
*/
$id_result = mysql_query ("SELECT * FROM
livres",$id_connex);
if(!$id_result){ echo "Lecture impossible, erreur
N",mysql_errno(),mysql_error();}
// nombre de lignes et de colonnes
$nbligne = mysql_num_rows($id_result);
$nbcol = mysql_num_fields($id_result);
echo "Il y a ",$nbligne, " livres dans la slection <br/
>";
for ($i=0;$i<$nbligne;$i++)
{
echo "Livre n",$i+1,"<br />";
$tablivres = mysql_fetch_row($id_result);
for ($j=0;$j<$nbcol;$j++)
{
echo $tablivres[$j],"<br />";
}
}
mysql_close($id_connex);
?>
</body>
</html>





page94.php3

<html>
<body>
<h3>LECTURE DES DONNEES </h3>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_selectdb("monlogin",$id_connex);
/*Cration avec une requte SQL de la base nomme"mabase"
*/
$id_result = mysql_query ("SELECT * FROM
livres",$id_connex);
if(!$id_result){ echo "Lecture impossible, erreur
N",mysql_errno(),mysql_error();}
// nombre de lignes et de colonnes
$nbligne = mysql_num_rows($id_result);
$nbcol = mysql_num_fields($id_result);
echo "Il y a ",$nbligne, " livres dans la slection <br/
>";
for ($i=0;$i<$nbligne;$i++)
{
echo "Livre n",$i+1,"<br />";
$tablivres = mysql_fetch_row($id_result);
for ($j=0;$j<$nbcol;$j++)
{
echo $tablivres[$j],"<br />";
}
}
mysql_close($id_connex);
?>
</body>
</html>




lectureobjet.php3

<html>
<body>
<h3>LIRE LES DONNEES D'UNE TABLE </h3>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
//Requte SQL
$requete="SELECT * FROM livres ";
$id_result = mysql_query($requete,$id_connex);
if(!$id_result)
{ echo "Lecture impossible erreur N ",
mysql_errno(),mysql_error();}
//Affichage du nombre de lignes
echo"Il y a ",mysql_num_rows($id_result)," lignes de
rsultats <br /><br />";
//Affichage de tous les rsultats
while($tabobjet= mysql_fetch_object($id_result)) {
echo "Titre : ",$tabobjet->titre,"<br />";
echo "Auteur : ",$tabobjet->auteur,"<br />";
echo "Collection : ",$tabobjet->collec," ISBN :
",$tabobjet->isbn,"<br />";
echo "Paru le : ",$tabobjet->paru,"<br /><br />";
}
mysql_close($id_connex);
?>
</body>
</html>




page96.php3

<html>
<body>
<h3>LIRE LES DONNEES D'UNE TABLE </h3>
<?php
$id_connex = mysql_connect ("localhost", "root","")or
die("CONNEXION IMPOSSIBLE");
mysql_select_db("monlogin",$id_connex);
//Requte SQL
$requete="SELECT * FROM livres ";
$id_result = mysql_query($requete,$id_connex);
if(!$id_result)
{ echo "Lecture impossible erreur N ",
mysql_errno(),mysql_error();}
//Affichage du nombre de lignes
echo"Il y a ",mysql_num_rows($id_result)," lignes de
rsultats <br /><br />";
//Affichage de tous les rsultats
while($tabobjet= mysql_fetch_object($id_result)) {
echo "Titre : ",$tabobjet->titre,"<br />";
echo "Auteur : ",$tabobjet->auteur,"<br />";
echo "Collection : ",$tabobjet->collec," ISBN :
",$tabobjet->isbn,"<br />";
echo "Paru le : ",$tabobjet->paru,"<br /><br />";
}
mysql_close($id_connex);
?>
</body>
</html>




page98.php3

<html>
<body>
<h3>LECTURE DES DONNEES </h3>
<?php
$id_connex = mysql_connect ("localhost", "root","")or die("CONNEXION IMPOSSIBLE");
mysql_selectdb("monlogin",$id_connex);
//requte de slection
$id_result = mysql_query ("SELECT * FROM livres",$id_connex);
if(!$id_result){ echo "Lecture impossible, erreur N",mysql_errno(),mysql_error();}
//Nombre de lignes et de colonnes
$nblignes= mysql_num_rows($id_result);
$nbcol= mysql_num_fields($id_result);
echo "Il y a ",$nblignes, " livres dans la slection <br/>";
echo "Il y a ",$nbcol, " colonnes par ligne <br/>";
//Boucles de lecture des donnes
for($i=0;$i<$nblignes;$i++)
{
for($j=0;$j<$nbcol;$j++)
{
echo "<b> : ",mysql_result($id_result,$i,$j),"<br/>";
}
}
mysql_close($id_connex);
?>
</body>
</html>




formrecherche.htm

<html>
<head>
<title>Site livres OEM</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<h3><img src="Oem200.gif" width="400" height="63" border="2"></h3>
<h3 align="left"> Recherche de livre:</h3>
<form method="post" action="recherche.php3">
<table width="400" border="8">
<tr bordercolor="#CCCCCC">
<td width="45%"><b>Rechercher : </b></td>
<td width="55%">
<input type="text" name="choix" maxlength="30" size="30">
</td>
</tr>
<tr bordercolor="#CCCCCC">
<td width="45%"><b>Crit&egrave;re de recherche</b></td>
<td width="55%">
<select name="critere" size="1">
<option selected><b>Titre</b></option>
<option>Auteur</option>
<option>Collection</option>
<option>ISBN</option>
</select>
</td>
</tr>
<tr>
<td width="45%"><b>Afficher par ordre:</b></td>
<td width="55%">Croissant
<input type="radio" name="ordre" value="ASC">
d&eacute;croissant
<input type="radio" name="ordre" value="DESC">
</td>
</tr>
<tr>
<td width="45%">
<div align="center">
<input type="reset" name="reset" value="Effacer">
</div>
</td>
<td width="55%">
<div align="center">
<input type="submit" name="submit" value="Envoyer">
</div>
</td>
</tr>
</table>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>




page103.htm

<html>
<head>
<title>Site livres OEM</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<h3><img src="Oem200.gif" width="400" height="63" border="2"></h3>
<h3 align="left"> Recherche de livre:</h3>
<form method="post" action="recherche.php3">
<table width="400" border="8">
<tr bordercolor="#CCCCCC">
<td width="45%"><b>Rechercher : </b></td>
<td width="55%">
<input type="text" name="choix" maxlength="30" size="30">
</td>
</tr>
<tr bordercolor="#CCCCCC">
<td width="45%"><b>Crit&egrave;re de recherche</b></td>
<td width="55%">
<select name="critere" size="1">
<option selected><b>Titre</b></option>
<option>Auteur</option>
<option>Collection</option>
<option>ISBN</option>
</select>
</td>
</tr>
<tr>
<td width="45%"><b>Afficher par ordre:</b></td>
<td width="55%">Croissant
<input type="radio" name="ordre" value="ASC">
d&eacute;croissant
<input type="radio" name="ordre" value="DESC">
</td>
</tr>
<tr>
<td width="45%">
<div align="center">
<input type="reset" name="reset" value="Effacer">
</div>
</td>
<td width="55%">
<div align="center">
<input type="submit" name="submit" value="Envoyer">
</div>
</td>
</tr>
</table>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>




recherche.php3

<html>
<body>
<img src="Oem200.gif" width="350" height="63">
<?php
$id_connex = mysql_connect ("localhost", "root","")or die("CONNEXION IMPOSSIBLE");
mysql_selectdb("monlogin",$id_connex);
//recherche
switch($critere)
{
case "Titre":
$requete = "SELECT * FROM livres WHERE titre LIKE '%$choix%' ORDER BY titre ".$ordre;
break;
case "Auteur":
$requete = "SELECT * FROM livres WHERE auteur LIKE '%$choix%' ORDER BY paru ".$ordre;
break;
case "Collection":
$requete = "SELECT * FROM livres WHERE collec LIKE '%$choix%' ORDER BY paru ".$ordre;
break;
case "ISBN":
$requete = "SELECT * FROM livres WHERE isbn LIKE '%$choix%' ORDER BY isbn ".$ordre;
break;
}
//envoi de la requte
$id_result = mysql_query ($requete,$id_connex);
if(!$id_result){ echo "Lecture impossible, erreur N",mysql_errno(),mysql_error();}
//lecture du nombre de lignes du rsultat
$nblignes= mysql_num_rows($id_result);
echo "<h2> Rsultat : Il y a $nblignes livres dans la slection </h2>";
//affichage des rsultats sous forme de tableau HTML
while($tablivres =
mysql_fetch_array($id_result,MYSQL_ASSOC))
{
echo "<table width=\"400\" border=\"5\">";
echo" <tr>" ;
echo" <td align=\"center\" width=\"30%\" > ";
echo "<img src=\"$tablivres[image]\" ></td> ";
echo"<td width=\"70%\" height=\"195\" rowspan=\"2\"> <h2>{$tablivres[titre]}</h2> <br/><b>{$tablivres[auteur]}</b><br/>Collection :
{$tablivres[collec]} <br/>Paru le: {$tablivres[paru]} <br/>Code isbn: {$tablivres[isbn]}&nbsp;</td>";
echo"</tr>";
echo"</table><br/>";
}
mysql_close($id_connex);
?>
</body>
</html>




page105.php3

<html>
<body>
<img src="Oem200.gif" width="350" height="63">
<?php
$id_connex = mysql_connect ("localhost", "root","")or die("CONNEXION IMPOSSIBLE");
mysql_selectdb("monlogin",$id_connex);
//recherche
switch($critere)
{
case "Titre":
$requete = "SELECT * FROM livres WHERE titre LIKE '%$choix%' ORDER BY titre ".$ordre;
break;
case "Auteur":
$requete = "SELECT * FROM livres WHERE auteur LIKE '%$choix%' ORDER BY paru ".$ordre;
break;
case "Collection":
$requete = "SELECT * FROM livres WHERE collec LIKE '%$choix%' ORDER BY paru ".$ordre;
break;
case "ISBN":
$requete = "SELECT * FROM livres WHERE isbn LIKE '%$choix%' ORDER BY isbn ".$ordre;
break;
}
//envoi de la requte
$id_result = mysql_query ($requete,$id_connex);
if(!$id_result){ echo "Lecture impossible, erreur N",mysql_errno(),mysql_error();}
//lecture du nombre de lignes du rsultat
$nblignes= mysql_num_rows($id_result);
echo "<h2> Rsultat : Il y a $nblignes livres dans la slection </h2>";
//affichage des rsultats sous forme de tableau HTML
while($tablivres =
mysql_fetch_array($id_result,MYSQL_ASSOC))
{
echo "<table width=\"400\" border=\"5\">";
echo" <tr>" ;
echo" <td align=\"center\" width=\"30%\" > ";
echo "<img src=\"$tablivres[image]\" ></td> ";
echo"<td width=\"70%\" height=\"195\" rowspan=\"2\"> <h2>{$tablivres[titre]}</h2> <br/><b>{$tablivres[auteur]}</b><br/>Collection :
{$tablivres[collec]} <br/>Paru le: {$tablivres[paru]} <br/>Code isbn: {$tablivres[isbn]}&nbsp;</td>";
echo"</tr>";
echo"</table><br/>";
}
mysql_close($id_connex);
?>
</body>
</html>




index.php3

<html>
<head>
<title>Mes annonces gratuites</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><img src="annonces1.gif" width="400" height="84"></p>
<?php
echo "<h3>Bonjour $nom: Aujourd'hui ". date('d/m/Y')." </h3>";
?>
<table width="400" border="4" height="55">
<tr>
<td colspan="3" height="50">
<div align="center">
<h3><b>Passer une annonce</b> </h3>
</div>
</td>
</tr>
<tr>
<td width="133" height="33">
<div align="center"><b><a
href="formauto.php3">Auto</a></b></div>
</td>
<td width="134" height="33">
<div align="center"><b><a
href="formimmo.php3">Immobilier</a></b></div>
</td>
<td width="133" height="33">
<div align="center"> <b><a
href="formdiv.php3">Divers</a> </b> </div>
</td>
</tr>
<tr>
<td height="56" colspan="3">
<h3 align="center"><b>Lire les annonces</b></h3>
</td>
</tr>
<tr>
<td width="109" height="31">
<div align="center"><b><a href="lectauto.php3">Auto</a></b></div>
</td>
<td width="134" height="31">
<div align="center"><b><a href="lectauto.php3"> </a>
<a href="lectimmo.php3">Immobilier</a>
</b>
</div>
</td>
<td width="129" height="31">
<div align="center"><b><a href="formdiv.php3">Divers</a></b></div>
</td>
</tr>
<tr>
<td height="55" colspan="3">
<div align="center">
<h3><a href="formsuppr.php3">Supprimer une annonce</a></h3>
</div>
</td>
</tr>
</table>
<h3 align="left">&nbsp;</h3>
</body>
</html>




page112.php3

<html>
<head>
<title>Mes annonces gratuites</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><img src="annonces1.gif" width="400" height="84"></p>
<?php
echo "<h3>Bonjour $nom: Aujourd'hui ". date('d/m/Y')." </h3>";
?>
<table width="400" border="4" height="55">
<tr>
<td colspan="3" height="50">
<div align="center">
<h3><b>Passer une annonce</b> </h3>
</div>
</td>
</tr>
<tr>
<td width="133" height="33">
<div align="center"><b><a
href="formauto.php3">Auto</a></b></div>
</td>
<td width="134" height="33">
<div align="center"><b><a
href="formimmo.php3">Immobilier</a></b></div>
</td>
<td width="133" height="33">
<div align="center"> <b><a
href="formdiv.php3">Divers</a> </b> </div>
</td>
</tr>
<tr>
<td height="56" colspan="3">
<h3 align="center"><b>Lire les annonces</b></h3>
</td>
</tr>
<tr>
<td width="109" height="31">
<div align="center"><b><a href="lectauto.php3">Auto</a></b></div>
</td>
<td width="134" height="31">
<div align="center"><b><a href="lectauto.php3"> </a>
<a href="lectimmo.php3">Immobilier</a>
</b>
</div>
</td>
<td width="129" height="31">
<div align="center"><b><a href="formdiv.php3">Divers</a></b></div>
</td>
</tr>
<tr>
<td height="55" colspan="3">
<div align="center">
<h3><a href="formsuppr.php3">Supprimer une annonce</a></h3>
</div>
</td>
</tr>
</table>
<h3 align="left">&nbsp;</h3>
</body>
</html>





formauto.php3

<html>
<head>
<title>Passer une annonce automobile</title>
</head>
<body bgcolor="#FFFFFF">
<p><img src="annonces1.gif" width="400" height="88"> </p>
<p align="left"><font size="3"></font></p>
<form method="post" action="stockauto.php3">
<table width="399" border="0">
<tr>
<td colspan="4">
<div align="center"><font size="3"><b><font size="4">Saisie d'annonce
: rubrique automobile</font></b></font></div>
</td>
</tr>
<tr>
<td height="25" colspan="4" >Choisissez la dur&eacute;e de l'annonce :
<select name="duree" size="1">
<option value="604800">Une semaine</option>
<option value="1209600">Deux semaines</option>
<option value="1814400">Trois semaines</option>
</select>
</td>
</tr>
<tr>
<td width="81" height="25" >Votre nom: </td>
<td height="25" colspan="3" >
<input type="text" name="nom" size="40">
</td>
</tr>
<tr>
<td width="81" >Marque:</td>
<td width="130">
<select name="marque" size="1">
<option value="renault">Renault</option>
<option value="peugeot">Peugeot</option>
<option value="citroen">Citro&euml;n</option>
<option value="ford">Ford</option>
<option value="volkswagen">Volkswagen</option>
<option value="autres">Autres</option>
</select>
</td>
<td width="50">Mod&egrave;le:</td>
<td width="131" height="25" >
<input type="text" name="modele" maxlength="10">
</td>
</tr>
<tr>
<td width="81">
<div align="center">Carburant : </div>
</td>
<td width="130">
<select name="carbu">
<option value="ess">Essence</option>
<option value="die">Diesel</option>
<option value="gpl">GPL</option>
</select>
</td>
<td width="50">Ann&eacute;e:</td>
<td width="131">
<input type="text" name="annee">
</td>
</tr>
<tr>
<td colspan="4"> <b>PRIX</b> <b>DE VENTE : </b>
<input type="text" name="prix">
</td>
</tr>
<tr>
<td colspan="4">
<textarea name="texte" rows="6" cols="50"></
textarea>
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="submit"
value="Enregistrer l'annonce">
</td>
<td width="50">&nbsp;</td>
<td width="131">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" name="reset" value="Effacer">
</td>
</tr>
</table>
</form>
<a href="index.php3"> Page d'accueil </a>
</body>
</html>




page115.php3

<html>
<head>
<title>Passer une annonce automobile</title>
</head>
<body bgcolor="#FFFFFF">
<p><img src="annonces1.gif" width="400" height="88"> </p>
<p align="left"><font size="3"></font></p>
<form method="post" action="stockauto.php3">
<table width="399" border="0">
<tr>
<td colspan="4">
<div align="center"><font size="3"><b><font size="4">Saisie d'annonce
: rubrique automobile</font></b></font></div>
</td>
</tr>
<tr>
<td height="25" colspan="4" >Choisissez la dur&eacute;e de l'annonce :
<select name="duree" size="1">
<option value="604800">Une semaine</option>
<option value="1209600">Deux semaines</option>
<option value="1814400">Trois semaines</option>
</select>
</td>
</tr>
<tr>
<td width="81" height="25" >Votre nom: </td>
<td height="25" colspan="3" >
<input type="text" name="nom" size="40">
</td>
</tr>
<tr>
<td width="81" >Marque:</td>
<td width="130">
<select name="marque" size="1">
<option value="renault">Renault</option>
<option value="peugeot">Peugeot</option>
<option value="citroen">Citro&euml;n</option>
<option value="ford">Ford</option>
<option value="volkswagen">Volkswagen</option>
<option value="autres">Autres</option>
</select>
</td>
<td width="50">Mod&egrave;le:</td>
<td width="131" height="25" >
<input type="text" name="modele" maxlength="10">
</td>
</tr>
<tr>
<td width="81">
<div align="center">Carburant : </div>
</td>
<td width="130">
<select name="carbu">
<option value="ess">Essence</option>
<option value="die">Diesel</option>
<option value="gpl">GPL</option>
</select>
</td>
<td width="50">Ann&eacute;e:</td>
<td width="131">
<input type="text" name="annee">
</td>
</tr>
<tr>
<td colspan="4"> <b>PRIX</b> <b>DE VENTE : </b>
<input type="text" name="prix">
</td>
</tr>
<tr>
<td colspan="4">
<textarea name="texte" rows="6" cols="50"></
textarea>
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="submit"
value="Enregistrer l'annonce">
</td>
<td width="50">&nbsp;</td>
<td width="131">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" name="reset" value="Effacer">
</td>
</tr>
</table>
</form>
<a href="index.php3"> Page d'accueil </a>
</body>
</html>




stockauto.php3

<?php
setcookie("nom",$nom,time()+3600);
?>
<html>
<head><title> Annonces automobile </title>
</head>
<body>
<?php
$id_connex=mysql_connect("localhost","root","") or die("Connexion impossible");
mysql_select_db("monlogin",$id_connex);
$requete="INSERT INTO auto(marque,modele,carbu,annee,prix,texte,datefin) VALUES('$marque','$modele','$carbu','$annee',$prix,'$texte',now()+$duree)";
$verif = mysql_query($requete,$id_connex);
if($verif)
{
echo "<script language=\"JavaScript\">";
$message="Veuillez noter le code de l'annonce:"."auto-".mysql_insert_id();
echo "window.alert(\" ".$message."\");
</script>";
}
else {echo "Insertion impossible erreur N ",mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
<a href="index.php3"> Page d'accueuil </a>
</body>
</html>




page118.php3

<?php
setcookie("nom",$nom,time()+3600);
?>
<html>
<head><title> Annonces automobile </title>
</head>
<body>
<?php
$id_connex=mysql_connect("localhost","root","") or die("Connexion impossible");
mysql_select_db("monlogin",$id_connex);
$requete="INSERT INTO auto(marque,modele,carbu,annee,prix,texte,datefin) VALUES('$marque','$modele','$carbu','$annee',$prix,'$texte',now()+$duree)";
$verif = mysql_query($requete,$id_connex);
if($verif)
{
echo "<script language=\"JavaScript\">";
$message="Veuillez noter le code de l'annonce:"."auto-".mysql_insert_id();
echo "window.alert(\" ".$message."\");
</script>";
}
else {echo "Insertion impossible erreur N ",mysql_errno(),mysql_error();}
mysql_close($id_connex);
?>
<a href="index.php3"> Page d'accueuil </a>
</body>
</html>




 lectauto.php3

<html>
<head>
<title>Lire les annonces automobile</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><img src="annonces1.gif" width="400" height="88"> </p>
<p align="left"><font size="3"></font></p>
<form method="post" action="selectauto.php3">
<table width="399" border="0">
<tr>
<td colspan="4">
<div align="center"><font size="3"><b><font size="4">Lire les annonces: rubrique automobile</font></b></font></div>
</td>
</tr>
<tr>
<td width="75" ><b>Marque</b></td>
<td width="90">
<select name="marque" size="1">
<option value="renault">Renault</option>
<option value="peugeot">Peugeot</option>
<option value="citroen">Citro&euml;n</option>
<option value="ford">Ford</option>
<option value="volkswagen">Volkswagen</option>
<option value="autres">Autres</option>
</select>
</td>
<td width="101"><b>Mod&egrave;le</b></td>
<td width="130" height="25" >
<input type="text" name="modele" maxlength="10">
</td>
</tr>
<tr>
<td width="75">
<div align="center"><b>Carburant</b> </div>
</td>
<td width="90">
<select name="carbu" size="1">
<option value="ess">Essence</option>
<option value="die">Diesel</option>
<option value="gpl">GPL</option>
</select>
</td>
<td width="101"><b>Ann&eacute;e </b></td>
<td width="130">
<input type="text" name="annee" value="1990" maxlength="4">
</td>
</tr>
<tr>
<td colspan="4"><b>Prix maximum
d&eacute;sir&eacute;:
<input type="text" name="prixmax" value="100000" >
Francs</b></td>
</tr>
<tr>
<td colspan="2">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="envoi" value="Chercher!">
</td>
<td width="101">
<div align="center"><img src="auto1.gif" width="32" height="32"></div>
</td>
<td width="130">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" name="reset" value="Effacer">
</td>
</tr>
</table>
</form>
</body>
</html>





page120.php3

<html>
<head>
<title>Lire les annonces automobile</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><img src="annonces1.gif" width="400" height="88"> </p>
<p align="left"><font size="3"></font></p>
<form method="post" action="selectauto.php3">
<table width="399" border="0">
<tr>
<td colspan="4">
<div align="center"><font size="3"><b><font size="4">Lire les annonces: rubrique automobile</font></b></font></div>
</td>
</tr>
<tr>
<td width="75" ><b>Marque</b></td>
<td width="90">
<select name="marque" size="1">
<option value="renault">Renault</option>
<option value="peugeot">Peugeot</option>
<option value="citroen">Citro&euml;n</option>
<option value="ford">Ford</option>
<option value="volkswagen">Volkswagen</option>
<option value="autres">Autres</option>
</select>
</td>
<td width="101"><b>Mod&egrave;le</b></td>
<td width="130" height="25" >
<input type="text" name="modele" maxlength="10">
</td>
</tr>
<tr>
<td width="75">
<div align="center"><b>Carburant</b> </div>
</td>
<td width="90">
<select name="carbu" size="1">
<option value="ess">Essence</option>
<option value="die">Diesel</option>
<option value="gpl">GPL</option>
</select>
</td>
<td width="101"><b>Ann&eacute;e </b></td>
<td width="130">
<input type="text" name="annee" value="1990" maxlength="4">
</td>
</tr>
<tr>
<td colspan="4"><b>Prix maximum
d&eacute;sir&eacute;:
<input type="text" name="prixmax" value="100000" >
Francs</b></td>
</tr>
<tr>
<td colspan="2">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="envoi" value="Chercher!">
</td>
<td width="101">
<div align="center"><img src="auto1.gif" width="32" height="32"></div>
</td>
<td width="130">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" name="reset" value="Effacer">
</td>
</tr>
</table>
</form>
</body>
</html>


selectauto.php3

<html>
<body>
<img src="annonces1.gif" width="400" height="63">
<?php
$id_connex = mysql_connect ("localhost", "root","")or die("CONNEXION IMPOSSIBLE");
mysql_selectdb("monlogin",$id_connex);
// requte SQL
$requete = "SELECT * FROM auto WHERE (marque = '$marque') AND (modele LIKE '%$modele%') AND (carbu = '$carbu') AND (annee >$annee) AND (prix<$prixmax) ORDER BY prix ";
$id_result = mysql_query ($requete,$id_connex);
if(!$id_result){ echo "Lecture impossible, erreur N",mysql_errno(),mysql_error();}
//lecture du nombre de lignes du rsultat
$nblignes= mysql_num_rows($id_result);
echo "<h3> Rsultat : Il y a $nblignes voitures dans la slection </h3>";
//affichage des rsultats sous forme de tableau HTML
while($tabauto =
mysql_fetch_array($id_result,MYSQL_ASSOC))
{
echo "<table width=\"400\" border=\"5\">";
echo"<tr><td> <h2>{$tabauto[marque]} {$tabauto[modele]} {$tabauto[annee]}: {$tabauto[prix]} Francs</h2> {$tabauto[texte]}</td></tr>";
echo"<br/>";
}
mysql_close($id_connex);
?>
</body>
</html>




page123.php3

<html>
<body>
<img src="annonces1.gif" width="400" height="63">
<?php
$id_connex = mysql_connect ("localhost", "root","")or die("CONNEXION IMPOSSIBLE");
mysql_selectdb("monlogin",$id_connex);
// requte SQL
$requete = "SELECT * FROM auto WHERE (marque = '$marque') AND (modele LIKE '%$modele%') AND (carbu = '$carbu') AND (annee >$annee) AND (prix<$prixmax) ORDER BY prix ";
$id_result = mysql_query ($requete,$id_connex);
if(!$id_result){ echo "Lecture impossible, erreur N",mysql_errno(),mysql_error();}
//lecture du nombre de lignes du rsultat
$nblignes= mysql_num_rows($id_result);
echo "<h3> Rsultat : Il y a $nblignes voitures dans la slection </h3>";
//affichage des rsultats sous forme de tableau HTML
while($tabauto =
mysql_fetch_array($id_result,MYSQL_ASSOC))
{
echo "<table width=\"400\" border=\"5\">";
echo"<tr><td> <h2>{$tabauto[marque]} {$tabauto[modele]} {$tabauto[annee]}: {$tabauto[prix]} Francs</h2> {$tabauto[texte]}</td></tr>";
echo"<br/>";
}
mysql_close($id_connex);
?>
</body>
</html>




formsuppr.php3

<html>
<body>
<p><img src="annonces1.gif" width="400" height="63">
<h3>Supprimer une annonce</h3>
<form method="post" action="delete.php3">
<p>Tapez le code de l'annonce:
<input type="text" name="code">
</p>
<p>
<input type="submit" name="supprimer" value="Supprimer l'annonce">
</p>
</form>
</body>
</html>




page124-1.php3

<html>
<body>
<p><img src="annonces1.gif" width="400" height="63">
<h3>Supprimer une annonce</h3>
<form method="post" action="delete.php3">
<p>Tapez le code de l'annonce:
<input type="text" name="code">
</p>
<p>
<input type="submit" name="supprimer" value="Supprimer l'annonce">
</p>
</form>
</body>
</html>




delete.php3

<?php
$id_connex = mysql_connect ("localhost", "root","")or die("CONNEXION IMPOSSIBLE");
mysql_selectdb("monlogin",$id_connex);
//sparation du code de l'annonce
$codeann= explode("-",$code);
//numro de l'annonce
$num= $codeann[1];
//nom de la table
$table =$codeann[0];
//nom du champ
$id_ann = "id_".$table;
$requete = "DELETE FROM $table WHERE $id_ann =$num";
$verif = mysql_query ($requete,$id_connex);
if($verif){
echo "L'annonce est supprime";
}
mysql_close($id_connex);
?>



page124-2.php3

<?php
$id_connex = mysql_connect ("localhost", "root","")or die("CONNEXION IMPOSSIBLE");
mysql_selectdb("monlogin",$id_connex);
//sparation du code de l'annonce
$codeann= explode("-",$code);
//numro de l'annonce
$num= $codeann[1];
//nom de la table
$table =$codeann[0];
//nom du champ
$id_ann = "id_".$table;
$requete = "DELETE FROM $table WHERE $id_ann =$num";
$verif = mysql_query ($requete,$id_connex);
if($verif){
echo "L'annonce est supprime";
}
mysql_close($id_connex);
?>
