[RESOLU] probleme pour afficher un tableau

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : [RESOLU] probleme pour afficher un tableau

Re: probleme pour afficher un tableau

par moogli » 06 août 2012, 20:13

salut,

c'est normale tu essai d'utiliser une méthode sur une chaine de caractère.
<?php
$req= "SELECT * FROM Commmentaires ";
//$req->execute();
$resultat=$req;
?>
un tuto sur PDO http://www.siteduzero.com/tutoriel-3-34 ... x-bdd.html


@+

probleme pour afficher un tableau

par imran2011 » 06 août 2012, 19:58

Salut
jai un probleme avec mon code
kan j'execute il affiche une erreur qui est:

Fatal error: Call to a member function fetch() on a non-object in C:\wampfinal\www\test\Admin\commentairesGestion.php on line 42
ligne 42 ce: <?php while($donnees=$resultat->fetch())
<?php session_start();if(!isset($_SESSION['login']))
//header('Location:../index.php'); require_once('../Connections/maconnexion.php'); 


if(isset($_GET['supp']))
{
	$requete2='DELETE FROM commmentaires WHERE id='.$_GET['id'];
	$pdo->query($requete2);
}
//----Requete liste
$req= "SELECT * FROM Commmentaires ";
//$req->execute();
$resultat=$req;

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <link rel="stylesheet" href="style.css" />
       
        <title>page du gestion des commenatires</title>
    </head>
	<body>
		
                    <h1>GESTION DES COMMENTAIRE</h1>
                    

<br/>
<table width="600" border="1" cellspacing="0" cellpadding="5">
	<tr>
	    <td>id commentaire</td>
		<td>id du blog</td>
        <td>auteur</td>
		<td>texte du commentaire</td>
        <td>date du commentaire</td>
		<td>supp</td>
	</tr>
	<?php while($donnees=$resultat->fetch())  {?>
	<tr>
	    <td><?php echo $donnees['id']; ?></td>
        <td><?php echo $donnees['id_billet']; ?></td>
        <td><?php echo $donnees['auteur']; ?></td>
        <td><?php echo $donnees['commentaire']; ?></td>
		<td><?php echo $donnees['date_commentaire']; ?></td>
		
		<td><a href= "commentairesGestion.php?id=<?php echo $donnees['id'];?>&supp=ok">supp</a></td>
	</tr>
	<?php } ?>
</table>
				
						
					
					
               
    </body>
    </html>      
Merci de m'avoir aider