Good evening everybody,
We are beginners and unskilled in php html ...
this is the page which will allow us to display the books available to borrow them. For now we are at the stage display books. No error message is displayed, but the list of books is not displayed either.
-- phpMyAdmin SQL Dump
-- version 4.3.11
-- http://www.phpmyadmin.net
--
-- Client : 127.0.0.1
-- Généré le : Jeu 14 Mai 2015 à 19:02
-- Version du serveur : 5.6.24
-- Version de PHP : 5.6.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Base de données : `bibliotheque`
--
-- --------------------------------------------------------
--
-- Structure de la table `livres`
--
CREATE TABLE IF NOT EXISTS `livres` (
`ID_LIVRE` int(11) NOT NULL,
`NOM_LIVRE` varchar(255) NOT NULL,
`AUTEUR` varchar(255) NOT NULL,
`DATE_PARUTION` int(11) NOT NULL,
`PSEUDO_POSSESSEUR` varchar(255) NOT NULL,
`ETAT` tinyint(1) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
--
-- Contenu de la table `livres`
--
INSERT INTO `livres` (`ID_LIVRE`, `NOM_LIVRE`, `AUTEUR`, `DATE_PARUTION`, `PSEUDO_POSSESSEUR`, `ETAT`) VALUES
(5, 'Les fleurs du mal ', 'Charles Baudelaire', 1857, 'victor', 1),
(6, 'Les Misérables ', 'Victor Hugo', 1862, 'victor', 1),
(7, 'Les Liaisons dangereuses', 'Choderlos de Laclos', 1782, 'victor', 1),
(8, 'Madame Bovary', 'Gustave Flaubert ', 1857, 'victor', 1),
(9, 'Voyage au bout de la nuit', 'Céline ', 1932, 'victor', 1),
(10, 'Le Petit Prince ', 'Antoine de Saint-Exupéry', 1943, 'victor', 1);
-- --------------------------------------------------------
--
-- Structure de la table `utilisateurs`
--
CREATE TABLE IF NOT EXISTS `utilisateurs` (
`ID_UTILISATEURS` int(11) NOT NULL,
`NOM` varchar(255) NOT NULL,
`PRENOM` varchar(255) NOT NULL,
`PSEUDO` varchar(255) NOT NULL,
`MDP` varchar(255) NOT NULL,
`EMAIL` varchar(255) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;
--
-- Contenu de la table `utilisateurs`
--
INSERT INTO `utilisateurs` (`ID_UTILISATEURS`, `NOM`, `PRENOM`, `PSEUDO`, `MDP`, `EMAIL`) VALUES
(5, 'Mestiri', 'Taieb', 'mlazyscientist', '8673c156d028f0dddaf6cd2d0f3e3dc092c336de', 'mestiritaieb@gmail.com'),
(7, 'lauret', 'victor', 'victor', '563ff5da92544f70988a942d45d086496003a092', 'victorlauret@gmail.com');
--
-- Index pour les tables exportées
--
--
-- Index pour la table `livres`
--
ALTER TABLE `livres`
ADD PRIMARY KEY (`ID_LIVRE`);
--
-- Index pour la table `utilisateurs`
--
ALTER TABLE `utilisateurs`
ADD PRIMARY KEY (`ID_UTILISATEURS`);
--
-- AUTO_INCREMENT pour les tables exportées
--
--
-- AUTO_INCREMENT pour la table `livres`
--
ALTER TABLE `livres`
MODIFY `ID_LIVRE` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=11;
--
-- AUTO_INCREMENT pour la table `utilisateurs`
--
ALTER TABLE `utilisateurs`
MODIFY `ID_UTILISATEURS` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=8;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Now the PHP code:
<?php
// Démarrage de la session
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="../css/style.css" />
<title>La Bibliothéque MLC</title>
</head>
<body>
<div class="div_mere">
<img class="img1" src="../images/man216.png" />
<h1>La Bibliothéque MLC</h1>
<ul>
<li><a href="accueil_membre.html"> Accueil </a></li>
<li><a href="f_ajout_livre.html"> Ajouter un Document </a></li>
<li><a href="bdd_livres.html"> Emprunter un Document </a></li>
<li><a href="deconnexion.html"> Déconnexion </a></li>
</ul>
<a href="https://www.facebook.com/taieb.mestiri">
<img class="facebook" src="../images/facebook29.png" />
</a>
<a href="https://plus.google.com/u/0/101730232507385912281/posts">
<img class="gmail" src="../images/email118.png" />
</a>
</div>
<div class="div_general">
<?php include("bdd_livres.php"); ?>
</div>
</body>
</html>
<?php
try {
// On se connecte à MySQL
$bdd = new PDO('mysql:host=localhost;dbname=bibliotheque;charset=utf8', 'root', '');
} catch(Exception $e) {
// En cas d'erreur, on affiche un message et on arrête tout
die('Erreur : '.$e->getMessage());
}
// On récupère tout le contenu de la table livres
$reponse = $bdd->query('SELECT * FROM livres');
// On affiche chaque entrée une à une
while ($donnees = $reponse->fetch()) {
echo $donnees['NOM_LIVRE'], $donnees['AUTEUR'], $donnees['DATE_PARUTION'],$donnees['PSEUDO_POSSESSEUR']
}
$reponse->closeCursor(); // Termine le traitement de la requête
?>