Probleme avec fpdf
Résolu
plumebeille
Messages postés
12
Statut
Membre
-
plumebeille Messages postés 12 Statut Membre -
plumebeille Messages postés 12 Statut Membre -
j'ai un souci pour recuperer l'id de la ligne que jeveux passer a ma page imprimer.php en fait imprimer n'arrive pas a acceder a l'id ni meme a la base de donnees et je sais pas pourquoi voicimes pages:
mani-eff:
et imprimer.php
j'ai vraiment besoin de n'afficher qu'une seul ligne par recu je vous prie de bien vouloir m'aider
mani-eff:
<?php
session_start();
$bdd=new PDO('mysql:host=127.0.0.1;dbname=espace_membre; charset=utf8','root','');
if (isset($_GET['id']) AND $_GET['id']>0)
{
$getid = intval($_GET['id']);
$requser = $bdd->prepare('SELECT * FROM membres WHERE id=?');
$requser->execute(array($getid));
$userinfo = $requser->fetch();
?>
<?php
$bdd = new pdo('mysql:host=127.0.0.1;dbname=espace_reservation', 'root' , '');
$reservation = $bdd->query('SELECT * FROM reservation WHERE confirme=1 ORDER BY id DESC LIMIT 0,30');
if (isset($_GET['imprimer']) AND !empty($_GET['imprimer'])) {
$imprimer = (int) $_GET['imprimer'];
header("location:imprimer.php?imprimer=".$r['id']);
}
?>
<?php
if (isset($_POST['manivoy']))
{
header("location: mani-eff.php?id=".$_SESSION['id']);
}
if (isset($_POST['formvoyeff']))
{
header("location: profil.php?id=".$_SESSION['id']);
}
if (isset($_POST['edit']))
{
header("location: edit.php?id=".$_SESSION['id']);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>b-travellers</title>
<style>
html, body{
margin: 0;
padding: 0;
font-family: 'Trebuchet MS', Arial, sans-serif;
color: #80d0d0;
background-color: #F9429E;}
.side{
margin-top: 90px;
padding: 0;
}
ul{
list-style-type: none;
width: 30%;
height:100%;
line-height: 60px;
}
ul li{
display: block;
width: 100%;
}
ul li a{
display: block;
text-align: center;
text-decoration: none;
transition: transform 1s ease-in-out;
background-color: blanchedalmond;
margin-top: 1px;
}
ul li a:hover{
transform: translate(5%,0);
border:2px solid black;
border-radius: 5px;
}
form{
float: right;
}
aside{
margin-top: 95px;} }
section{
flex: 1.2;
position: center;
background-color:rgba(119,33,126,0.3);
box-shadow: 0px 2px 5px #1c1a19;
border-radius: 5px;
padding:0;
color: black;
font-size: 0.9em;
width: 95%;
height: 900px;
margin-left: 2.5%;
}
table{
margin-left: 2.5%;
margin-top: 20px;
}
footer{
height: 150px;
padding:0;
margin-top: 0;
background-color:rgba(119,33,126,0.3);
width: 95%;
margin-left: 2.5%;
}
.separateur{
height: 3px;
width: 5%;
border: none;
box-shadow: none;
background-color: blue;
}
footer h5{
color: #ff5b5b;
text-align: center;
}
footer a{
color: white;
margin-left: 150px;
}
footer a:hover{
color: #3498db;
}
footer p{
padding-top: 3%;
color: white;
text-align: center;
text-transform: uppercase;
font-weight: bold;
}
</style>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/pheader.css">
<link rel="stylesheet" type="text/css" href="css/norme.css">
</head>
<body>
<nav class="inner-body">
<header>
<nav class="menu">
<div class="inner">
<div class="m-left">
<h1><?php echo $userinfo['agence'] ?></h1>
<h1><?php echo $userinfo['nom'] ?></h1>
<img src="images/black.png" alt="B-TRAVELLERS" id="logo"/>
</div>
<div class="m-right">
<a href="index.php" class="m-link">deconnexion</a>
<a href="voyages.php" class="m-link">forum</a>
<a href="hebergements.php" class="m-link">message</a>
</div>
</div>
<div class="m-nav-toogle">
<span class="m-toogle-icon"></span>
</div>
</div>
</nav>
</header>
<img src="images/v-image.jpg" min-width="1260" min-height="600" width="auto" height="auto" />
<aside >
<h1>B-TRAVELLERS</h1>
<nav class="side">
<?php
if ($userinfo['id'] == $_SESSION['id']) {
?>
<form method="post" action="">
<tr>
<td width="23.75%"><input type="submit" name="manivoy" value="manifeste de voyages"></td>
</tr>
<tr>
<td width="23.75%"><input type="submit" name="formvoyeff" value="voyages effectués"></td>
</tr>
<tr>
<td width="23.75%"><input type="submit" name="manitent" value="manifeste de manutention"></td>
</tr>
<tr>
<td width="23.75%"><input type="submit" name="edit" value="edition de billet"></td>
</tr>
</form>
<?php
}
?>
</nav>
</aside>
<form action="#" method="post">
<input type="text" name="query" maxlength="80" width="20px" size="50%" id="query" placeholder="entrez vos elements de recherche">
<input type="submit" value="rechercher">
</form>
<section class="body">
<br>
<br>
<table border="1" width="95%">
<form method="post" action="">
<div>
<fieldset>
<tr>
<td>
<input type="text" name="a-depart" placeholder="agence de depart">
</td>
<td>
<input type="text" name="a-dest" placeholder="agence dest">
</td>
<td>
<input type="text" name="nom-conduct" placeholder="nom du conducteur">
</td>
<td>
<input type="text" name="obs" placeholder="observations">
</td>
<td>
<input type="text" name="dep" placeholder="carburant peage et autres">
</td>
</tr>
</fieldset>
</div>
</form>
<tr>
<td width="10%">id</td>
<td width="20%">nom</td>
<td width="30%">Agence</td>
<td width="35%">statu</td>
</tr>
<?php while ($r = $reservation->fetch()) { ?>
<tr>
<td width="10%"><?= $r['id'] ?></td>
<td width="20%"><?= $r['nom'] ?></td>
<td width="30%"><?= $r['agence'] ?></td>
<td width="35%"><li><?php if ($r['confirme'] != 0){ ?>
<a href="imprimer.php?imprimer=<?= $r['id']?>">imprimer</a>
<?php }?>
<?php } ?>
<tr>
<td><input type="submit" name="formen" value="enregistrer le voyage"></td>
</tr>
</table>
</section>
</nav>
<footer>
<p>
copyright © ETONDE EBOUEA EBENEZER 2018 ALL Right reserved.
</p>
</footer>
</nav>
</body>
</html>
<?php
}
?>
et imprimer.php
<?php
require('fpdf.php');
class PDF extends FPDF
{
function basicTable($header, $data)
{
//en-tete
foreach ($header as $col)
$this->Cell(40,7,$col,1);
$this->Ln();
//donnees
foreach($data as $row)
{
foreach ($row as $col)
$this->Cell(40,6,$col,1);
$this->Ln();
}
}
}
$bdd = new pdo('mysql:host=127.0.0.1;dbname=espace_reservation', 'root' , '');
$pdf=new FPDF();
$pdf->Addpage();
$pdf->SetFont('Arial','',12);
$pdf->MultiCell(0,10,'Date:'.date('d-m-y').'',"R",0);
$pdf->SetFont('Arial','B',11);
$pdf->cell(18,10,'',0);
//cellules en-tete
$pdf->Multicell(150,10,"Agence\nTel:000 00 00 00 00\nBP:0000-aaa",0);
$pdf->cell(70,8,'',0);
$pdf->Multicell(100,8,"Attention:voyageur priere de bien Vouloir confirmer votre reservation 30min avant le depart!",0);
//tableau
$pdf->Ln(23);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(50,8,'depart',1);
$pdf->Cell(50,8,'destination',1);
$pdf->Cell(40,8,'n° siege',1);
$pdf->Cell(40,8,'prix',1);
$pdf->SetFont('Arial','',8);
//recuperation des informations du client
$bdd = new pdo('mysql:host=127.0.0.1;dbname=espace_reservation', 'root' , '');
$reservation = $bdd->query('SELECT * FROM reservation WHERE id=?');
if (isset($_GET['imprimer']) AND !empty($_GET['imprimer']))
{
while ($r = $reservation->fetch()){
$pdf->Cell(50,8,$r['id'],1);
$pdf->Cell(50,8,$r['arrive'],1);
$pdf->Cell(40,8,$r['siege'],1);
$pdf->Cell(40,8,$r['prix'],1);
}
}
$pdf->output();
?>
j'ai vraiment besoin de n'afficher qu'une seul ligne par recu je vous prie de bien vouloir m'aider
A voir également:
- Probleme avec fpdf
- Fpdf utf8 ✓ - Forum PHP
- Problème superposition images FPDF ✓ - Forum PHP
- Insertion d'images avec FPDF ✓ - Forum Webmastering
- Librairie FPDF - Forum PHP
- Fpdf background image - Forum Webmastering
Après..si mes réponses ne te conviennent pas..tu peux aller voir ailleurs sans soucis...
Et si tu ne donnes pas les messages d'erreurs rencontrés... IMPOSSIBLE de te répondre !
Sans parler du fait que ton code mériterait une sacrée relecture...
Quand, par exemple, on trouve deux fois la connexion à ta bdd dans ton fichier imprimer.php....;
$bdd = new pdo('mysql:host=127.0.0.1;dbname=espace_reservation', 'root' , '');Quand on voit que tu fais un QUERY avec une variable.... sans faire de BIND à la variable en question.....
$reservation = $bdd->query('SELECT * FROM reservation WHERE id=?');Ligne qu'il est préférable de remplacer par un prepare / execute comme dans l'exemple que je t'ai donné dans mes liens justement...
//préparation de la requête et des variables $sql = "SELECT * FROM reservation WHERE id=?"; $datas = array($id); //Execution de la requete try{ $requete = $bdd -> prepare($sql) ; $requete->execute($datas) ; }catch(Exception $e){ // en cas d'erreur : echo " Erreur ! ".$e->getMessage(); echo " Les datas : " ; print_r($datas); }Bien entendu.. tu auras également suivit les recommandations de mon second lien.. comme la récupération PROPRE des variables AVANT de les utiliser....
if (isset($_GET['id']) AND !empty($_GET['id'])) { $getid = intval($_GET['id']); $requser = $bdd->prepare('SELECT * FROM reservation WHERE id=?'); $requser->execute(array($getid)); $r = $requser->fetch(); $pdf->cell(60,5,$r['nom'],1,0); $pdf->cell(40,5,$r['depart'],1,0); $pdf->cell(40,5,$r['arrive'],1,0); $pdf->cell(15,5,$r['prix'],1,0); $pdf->cell(34,5,$r['siege'],1,1); }