Appel de pages dynamiques en php

sodam -  
kij_82 Messages postés 4102 Date d'inscription   Statut Contributeur Dernière intervention   -
Bonjour à tous et à toutes;

Nous avons un problème pour appeller une page dynamique qui affiche les informations provenant d'une base de donnée (mysql).
ci-dessous notre code qui ne marche pas:

<? start sesssion ();?>
<html>
<head>
<title>Page d'accueil</title>
</head>

<body>
<?
include ("connection.php"); ?>
<? $sql="select * from categorie";
$query=mysql_db_query(base,$sql);
?>

<table width="100%" border="1">
<tr>
<td><h1 align="center">Forums disponibles </h1>
<table border =1 width="100%">
<tr ><th width="20%" >Nom Forum</th><th width="70%">Description</th>
<th width="10%">Nbre messages</th>
</tr>
<?
while($record = mysql_fetch_object($query))
{ ?>
<tr>
<td align="center"> <a href="Liste_Questions.php"><? echo $record->catlib;
$nom = $record->catlib;
$_SESSION['nom']= $nom;
?></a></td>
<td align="center"><? echo $record->description; ?> </td>
<td align="center"><? echo $record->NbreMess; ?> </td>
</tr>
<? } ?>
</table>

</td>
</tr>
</table>
</body>
</html>

2 réponses

  1. ric
     
    Bonjour
    Je ne vois pas.
    Peut être mysql_db_query() qui est obsolète.
    0
  2. kij_82 Messages postés 4102 Date d'inscription   Statut Contributeur Dernière intervention   857
     
    Essai comme ca : ca devrai déjà y avoir moins de faute :

    <?
    session_start(); // C'est comme ca et non "start sesssion ()"

    echo "
    <html>
    <head>
    <title>Page d\'accueil</title>
    </head>

    <body>";

    include ("connection.php"); // Ici la connexion

    $sql="select * from categorie";
    $query=mysql_db_query(base,$sql);

    echo "
    <table width=\"100%\" border=\"1\">
    <tr>
    <td><h1 align=\"center\">Forums disponibles </h1>
    <table border =1 width=\"100%\">
    <tr ><th width=\"20%\" >Nom Forum</th><th width=\"70%\">Description</th>
    <th width=\"10%\">Nbre messages</th>
    </tr>";

    while($record = mysql_fetch_object($query))
    {

    $nom = $record->catlib;
    $_SESSION['nom']= $nom;

    echo "<tr><td align=\"center\"> <a href=\"Liste_Questions.php\">".$nom."</a></td>";
    echo "<td align=\"center\">".$record->description."</td>";
    echo "<td align=\"center\">".$record->NbreMess."</td></tr>";
    }

    echo "
    </table>

    </td>
    </tr>
    </table>
    </body>
    </html>";

    ?>

    Recommandation : je n'ai pas changé d'endroit le $_SESSION mais je trouve ça très louche de le mettre dans ton while, car la valeur est à chaque fois écrasée !

    @++.
    0