Php

comment affiche t on les informations qui sont enregistrés dans la base de données?

5 réponses

  1. Contributeur
    Si tu en es là, il faut commencer par le commencement, apprends les bases du php.

    Direction le siteduzero par exemple.
    0
    1. je l'ai fait en fait j'ai le code mais je voit pas ce qui cloche
      0
      1. Contributeur
        Moi non plus je vois pas ce qui cloche...
        0
        1. ta meme pas vu le code tres drole çà
          0
          1. Contributeur
            et je fais comment pour t'aider si tu montres pas ton code ? :)
            0
        2. pour l'enregistrement

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <!-- DW6 -->
          <head>
          <!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
          <title>Page d'accueil</title>
          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
          <link rel="stylesheet" href="file:///C|/Program Files/Macromedia/Dreamweaver 8/Configuration/BuiltIn/StarterPages/mm_travel2.css" type="text/css" />
          <script language="JavaScript" type="text/javascript">

          //--------------- LOCALIZEABLE GLOBALS---------------
          var d=new Date();
          monthname= new Array("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre");
          //Ensure correct for language. English is "January 1, 2004"
          var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
          //--------------- END LOCALIZEABLE ---------------
          </script>
          </head>
          <body bgcolor="#C0DFFD">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr bgcolor="#3366CC">

          </tr>

          <tr bgcolor="#3366CC">
          <td height="64" colspan="3" id="tagline" valign="top" align="center"> </td>
          <td width="100%"> </td>
          </tr>

          <tr>
          <td colspan="7" bgcolor="#003366"><img src="file:///C|/Program Files/Macromedia/Dreamweaver 8/Configuration/BuiltIn/StarterPages/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
          </tr>

          <tr bgcolor="#CCFF99">
          <td colspan="7" id="dateformat" height="25">  <script language="JavaScript" type="text/javascript">
          document.write(TODAY); </script> </td>
          </tr>
          <tr>
          <td colspan="7" bgcolor="#003366"><img src="file:///C|/Program Files/Macromedia/Dreamweaver 8/Configuration/BuiltIn/StarterPages/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
          </tr>

          <tr>
          <td width="165" valign="top" bgcolor="#E6F3FF">
          <table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
          <tr>
          <td width="165" height="66"><p align="center"><strong><a href="file:///C|/Users/SOL INFO/Desktop/gestion/enregistrementservice.php">gestion d'un service </a></strong> </p> </tr>
          <tr>
          <td width="165"><p><a href="enregistrementformation.php" class="navText">gestion d'une formation </a></p>
          <p> </p></td>
          </tr>
          <tr>
          <td width="165"><p><a href="enregistrementparticipant.php" class="navText"> gestion des participants </a></p>
          <p> </p></td>
          </tr>
          <tr>
          <td width="165"><p> </p>
          <p><a href="enregistremendirection.php" class="navText">gestion des directions</a></p>
          <p> </p></td>
          </tr>
          </table>
          <div align="center"><strong><a href="pagedaccueil.php">ACCUEIL</a></strong><br />
             <br />
             <br />
             <br />
            </div></td>
          <td width="50">  </td>
          <td width="305" colspan="2" valign="top"><img src="file:///C|/Program Files/Macromedia/Dreamweaver 8/Configuration/BuiltIn/StarterPages/mm_spacer.gif" alt="" width="305" height="1" border="0" /><br />
           <br />
           <br />

          <p>Enregistrer service </p>

          <form name="form1" method="post" action="saveservice.php">
          <p>
          <label></label>
          </p>
          <p>Nom service :
          <label>
          <input type="text" name="nomservice"/>
          </label>
          </p>
          <p>Select direction:
          <label>
          <select name="id_direction" classe="texte" id="id_direction">
          <option value="0">..select..</option>
          <?PHP
          include('../conne/mysqlconnec.php');

          $sql='SELECT * FROM direction LIMIT 0,30 ';
          $req=mysql_query($sql);//or die('Erreur SQL!<br>' .$sql.'<br>'.mysql_error());
          if($req){

          while($row=mysql_fetch_array($req))
          {
          echo'<option value= " '.$row['id_direction'].'"> '.$row['nomdirection'].'</option>';
          }
          }else{
          $message='requete invalide:' .mysql_error(). "n";
          $message.='requete complete :' .$sql;
          }
          ?>
          </select>
          </label>

          </p>

          <table width="200" border="0" align="center">
          <tr>
          <td><label>
          <input type="submit" name="Submit" value="Enregistrer" />
          </label></td>
          <td><label>
          <input type="reset" name="Submit2" value="Supprimer" />
          </label></td>
          </tr>
          </table>
          <p> </p>
          </form>
          <form id="form2" name="form2" method="post" action="testservice.php">
          <label>
          <input type="submit" name="Submit3" value="visualiser" />
          </label>
          </form>

          </td>
          <td width="100%"> </td>
          </tr>
          </table>
          </body>
          </html>



          pour mettre dans la base de données

          <?php

          include('../conne/mysqlconnec.php');
          //$codeservice=$_POST['codeservice'];
          $nomservice=$_POST['nomservice'];
          //$id_direction=$_POST['id_direction'];

          //$nomsection=$_POST['nomsection'];

          if ($nomservice!='' )

          {
          $sql="INSERT INTO service VALUES ('','".$nomservice."','".$id_direction."',);";
          mysql_query($sql,$connect);
          header("Location: enregistrementservice.php");
          //}else{
          // header("Location:enregistrement_service.php?MSG =veuillez remplir tous les champs");
          }
          ?>

          pour afficher

          <?php
          /*define('DB_SERVER','localhost');
          define('DB_SERVER_USERNAME','root');
          define('DB_SERVER_PASSWORD','');
          define('DB_DATABASE','gestion');
          $db=mysql_connect('localhost','root','');
          mysql_select_db('gestion',$db);*/
          include('../conne/mysqlconnec.php');

          $sql='SELECT *FROM service INNER JOIN direction ON direction.id_direction=service.id_direction ';
          $req=mysql_query($sql)or die('Erreur SQL!<br>' .sql.'<br>'.mysql_error());

          while($data=mysql_fetch_assoc($req))

          {
          echo'<br>'.$data['id_service'].'='.$data['id_direction'].'='.$data['nomservice'];
          }

          mysql_close();
          ?>
          0
          1. Contributeur
            tu as une erreur ?

            Tes données sont bien enregistrées dans la base de données ?
            0
          2. oui j'ai revérifié a plusieurs reprises
            0
          3. Contributeur
            tu as une erreur ?
            0
          4. c'est ce que je demande
            0
          5. Contributeur
            à mon avis, si tu séparais l'étoile du FROM dans ta requête, ça ne pourrait aller que mieux, pour commencer.
            0