Tableau vide

Fermé
Rida - 21 mai 2010 à 10:17
 Rida - 24 mai 2010 à 22:01
Bonjour, j'ai un gros soucis pour mon projet en terminal GSI , j'ai un forum mais il n'affiche aucun topic lorsque je l'ai créé , voila la page menu de mon forum "main_forum"
Le probleme est que le tableau n'affiche pas les données enregistrées dans la base de donnée ce qui fait que le tableau est vide =( , merci de m'aider car je doit resoudre ce probleme avant mon oral en debut juin . Merci
( J'ai pris ce forum a partir de ce site http://www.phpeasystep.com/workshopview.php?id=12 )



<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Forums</title>
<link href="styleSun.css" title="Défaut" rel="stylesheet" type="text/css" media="screen" />
</head>

<body>

<div id="header"><div id="menuhorizontal"><ul id="menuhorizon"><!-- Menu horizontal -->
<center>
<li><a href="index.html" title="Ma description">Accueil</a></li>
<li><a href="qu'est qu'un prtice.htm" title="Ma description">Présentation</a></li>
<li><a href="formulaire.html" title="Ma description">Formulaire</a></li>
<li><a href="main_forum.php" title="Ma description">Forums</a></li>
</ul></div></div><!-- Fin Menu horizontal -->
<div id="right"><!-- Colonne de droite -->
<div id="hautmenu">Forums</div><!-- Début menu -->
</ul>
</div>
<div id="basmenu"></div><!-- Fin menu -->
</div><!-- Fin Colonne de droite -->
<div id="right"><!-- Colonne de Droite -->
<div class="fond_contenu">
<span> Forums :</span><br />
Vous êtes bien dans le forum du Lycée Sundar . <p>
Pour créer un sujet il vous suffit de remplir ce qui vous est demandé.
<p>
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="forum_question"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("Erreur Mysql");
mysql_select_db("$db_name")or die("Erreur base de données");

$sql="SELECT * FROM $tbl_name ORDER BY id DESC";
// OREDER BY id DESC is order result by descending
$result=mysql_query($sql);
?>

<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td>
<td width="53%" align="center" bgcolor="#E6E6E6"><strong>Sujet</strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>Vue</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Reponses</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Temps</strong></td>
</tr>

<?php
while($rows=mysql_fetch_array($result)){ // Start looping table row
?>
<tr>
<td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td>
<td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td>
</tr>

<?php
// Exit looping and close connection
}
mysql_close();
?>
<tr>
<td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_topic.php"><strong>Créer un nouveau sujet</strong> </a></td>
</tr>
</table>



A voir également:

2 réponses

killermano66 Messages postés 233 Date d'inscription jeudi 17 janvier 2008 Statut Membre Dernière intervention 25 novembre 2010 41
21 mai 2010 à 10:27
Tu as testé dans un analyseur que ta requête :

SELECT * FROM $tbl_name ORDER BY id DES

renvoi bien un résultat ?
0
Heuuu je vais êtres honnete je ne sais pas ce qu'est un analyseur =S , je suis en Terminal STG option GSI je n'ai que des notions de base sur le html php es ce possible d'avoir qlq eclaircissement ? Merci de m'avoir repondu killermano66
0