Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1442 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  Requète sur plusieurs lignes

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Requète sur plusieurs lignes

n°1758770
marygil
Posté le 12-07-2008 à 14:22:54  profilanswer
 

Bonjour,
 
J'ai une liste déroulante dans mon formulaire, provenant de ma BDD.
Dans une table j'ai un champ qui s'appelle "user_responsable".
Dans ce champ j'ai plusieurs valeurs, lorsque j'en sélectionne 5 (select multiple) je voudrais que sur mon site ça s'affiche sur 5 lignes et non comme cela se fait sur une seule ligne.
Merci beaucoup de votre aide.

mood
Publicité
Posté le 12-07-2008 à 14:22:54  profilanswer
 

n°1758799
l0g4n
Expert en tout :o
Posté le 12-07-2008 à 17:09:50  profilanswer
 

Quand tu affiche, tu fait :

Code :
  1. <?php
  2. echo $mavariable;
  3. echo $monautrevariable;
  4. ...
  5. ?>


Il te suffit d'ajouter le saut de ligne à chaque fois :

Code :
  1. <?php
  2. echo $mavariable;
  3. echo "<br />";
  4. echo $monautrevariable;
  5. echo "<br />";
  6. ...
  7. ?>


<br /> signifie saut de ligne en html.

n°1758843
marygil
Posté le 12-07-2008 à 20:17:48  profilanswer
 

Bonjour et merci de m'accorder un peu de temps...
Mais malheureusement je suis pas un expert en PHP mais ce code je n'ai l'ai pas du tout.
Alors je sais pas quoi faire.
Merci beaucoup

n°1758889
marygil
Posté le 12-07-2008 à 22:49:21  profilanswer
 

Voilà le code... et Merci

Code :
  1. <?php
  2.             //Menu déroulant pour la liste des responsabilités
  3.             $sql="show columns from  users like 'user_responsable'";
  4.             $result = DbConnection::select( $sql );
  5.             
  6.             if( DbConnection::hasError() )
  7.             {
  8.                 $error = DbConnection::getError();
  9.             }
  10.             if( $result )
  11.             {
  12.                 $type=mysql_result($result,0,'Type');
  13.                 $type=substr($type,5,strlen($type)-5-2);
  14.                 $resp=split("','",$type);
  15.                 
  16.                 //TODO multiple
  17.                 echo "<select multiple name='responsable'id='add-responsable'>";
  18.                 echo "<option selected value='-1'>--liste des responsabilites--</option>";
  19.                 
  20.                 /*echo "<option value = $resp[0]> $resp[0] </option>";
  21.                 echo "<option value = $resp[1]> $resp[1] </option>";
  22.                 echo "<option value = $resp[count($resp)-1]> $resp[count($resp)-1] </option>";*/
  23.                 
  24.                 foreach( $resp as $row )
  25.     {
  26.         echo "<option value=$row>$row</option>";
  27.     }
  28.  
  29.                 
  30.                 /*for ($i=0; $i<count($resp); $i++) {
  31.                     echo "<option value = $resp[i]> '$resp[i]' </option>";
  32.                 }*/
  33.                 
  34.                 /*while($row = mysql_fetch_array($resp))
  35.                 {
  36.                     echo "<option value=$data[0]>$data[0]</option>";
  37.                 }
  38. */                echo "</select>";
  39.             }
  40.             ?>

n°1758979
marygil
Posté le 13-07-2008 à 06:03:02  profilanswer
 

Cela doit correspondre à la ligne "323"
Merci

Code :
  1. <?php
  2. function dateFR( $time )
  3. {
  4.   setlocale( LC_TIME, "fr" );
  5.   return strftime( "%A %d %b %Y" , strtotime( $time ) );
  6. }
  7. function shortDateFR( $time )
  8. {
  9.   setlocale( LC_TIME, "fr" );
  10.   return strftime( "%b %Y" , strtotime( $time ) );
  11. }
  12. function birthDateFR( $time )
  13. {
  14.   setlocale( LC_TIME, "fr" );
  15.   return ( $time === '0000-00-00' ) ? '-' : strftime( "%d/%m/%Y" , strtotime( $time ) );
  16. }
  17. function dateSQL( $time )
  18. {
  19.     $regex = '`^(0[1-9]|1\d|2\d|3[0-1])\/(0[1-9]|1[0-2])\/(\d{4})$`';
  20.     $replace = '$3-$2-$1';
  21.     return preg_replace( $regex , $replace , $time );
  22. }
  23. class Membres
  24. {
  25.     static function displayList( $status )
  26.     {
  27.         if( $status === 'administrateur' )
  28.         {
  29.             if( isset( $_GET['view'] ) )
  30.             {
  31.                 $view = $_GET['view'];
  32.                 if( !in_array( $view , array ( 'all' , 'detail' ) ) )
  33.                 {
  34.                     $view = 'all';
  35.                 }
  36.                 elseif(  $view === 'detail' && isset( $_GET['id'] ) )
  37.                 {
  38.                     $id = (int) $_GET['id'];
  39.                 }
  40.             }
  41.             else
  42.             {
  43.                 $view = 'all';
  44.             }
  45.             if( isset( $_GET['sort'] ) && !empty( $_GET['sort'] ) )
  46.             {
  47.                 $sort = $_GET['sort'];
  48.                 if( !in_array( $sort , array ( 'user_name' , 'user_mail' ) ) )
  49.                 {
  50.                     $sort = 'user_name';
  51.                 }
  52.             }
  53.             else
  54.             {
  55.                 $sort = 'user_name';
  56.             }
  57.             if( isset( $_GET['order'] ) && !empty( $_GET['order'] ) )
  58.             {
  59.                 $order = $_GET['order'];
  60.                 if( !in_array( $order , array ( 'asc' , 'desc' ) ) )
  61.                 {
  62.                     $order = 'asc';
  63.                 }
  64.             }
  65.             else
  66.             {
  67.                 $order = 'asc';
  68.             }
  69.             if( isset( $_GET['start'] ) && !empty( $_GET['start'] ) )
  70.             {
  71.                 $start = (int) $_GET['start'];
  72.             }
  73.             else
  74.             {
  75.                 $start = 1;
  76.             }
  77.             if( $view === 'detail' )
  78.             {
  79.                 $sql = "SELECT `users`.`user_name`, `users`.`user_adress`, `users`.`user_tel1`, `users`.`user_tel2`, `users`.`user_mail`, `users`.`user_pupitres`, `users`.`user_membres` , `users`.`user_admission` , `users`.`user_demission`, `users`.`user_naissance`, `users`.`user_bureau`, `users`.`user_responsable` , `temp_reply`.`reply_count` FROM `users` LEFT JOIN ( SELECT `reply`.`user_id` , COUNT( `reply`.`user_id` ) AS `reply_count` FROM `reply` GROUP BY `reply`.`user_id` ) AS `temp_reply` ON `users`.`user_id` = `temp_reply`.`user_id` WHERE `users`.`user_id` = '$id' LIMIT 1;";
  80.                 $result = DbConnection::select( $sql );
  81.                 if( DbConnection::hasError() )
  82.                 {
  83.                     $error = DbConnection::getError();
  84.                 }
  85.                 if( $result )
  86.                 {
  87.                     $row = mysql_fetch_object( $result );
  88.                     $content = TXT_INDENT.TXT_INDENT.'<h3>Fiche de '.$row->user_name.'</h3>'.TXT_CRLF;
  89.                     $content .= TXT_INDENT.TXT_INDENT.'<p><strong>Adresse : </strong>'.stripslashes( $row->user_adress ).'</p>'.TXT_CRLF;
  90.                     $content .= TXT_INDENT.TXT_INDENT.'<p><strong>Téléphone 1 : </strong>'.$row->user_tel1.'</p>'.TXT_CRLF;
  91.                     $content .= TXT_INDENT.TXT_INDENT.'<p><strong>Téléphone 2 : </strong>'.$row->user_tel2.'</p>'.TXT_CRLF;
  92.                     $content .= TXT_INDENT.TXT_INDENT.'<p><strong>Courriel : </strong>'.$row->user_mail.'</p>'.TXT_CRLF;
  93.                     $content .= TXT_INDENT.TXT_INDENT.'<p><strong>Pupitre : </strong>'.$row->user_pupitres.'</p>'.TXT_CRLF;
  94.                     $content .= TXT_INDENT.TXT_INDENT.'<p><strong>Membre : </strong>'.$row->user_membres.'</p>'.TXT_CRLF;
  95.                     $content .= TXT_INDENT.TXT_INDENT.'<p><strong>Admission : </strong>'.birthDateFR( $row->user_admission ).'</p>'.TXT_CRLF;
  96.                     $content .= TXT_INDENT.TXT_INDENT.'<p><strong>Démission : </strong>'.birthDateFR( $row->user_demission ).'</p>'.TXT_CRLF;
  97.                     $content .= TXT_INDENT.TXT_INDENT.'<p><strong>Né(e) le : </strong>'.birthDateFR( $row->user_naissance ).'</p>'.TXT_CRLF;
  98.                     $content .= TXT_INDENT.TXT_INDENT.'<p><strong>Bureau : </strong>'.$row->user_bureau.'</p>'.TXT_CRLF;
  99.                     $content .= TXT_INDENT.TXT_INDENT.'<p><strong>Responsable : </strong>'.$row->user_responsable.'</p>'.TXT_CRLF;
  100.                     $content .= TXT_INDENT.TXT_INDENT.'<p class="button">[ <a onclick="displayBox(\'requests/membres.php5?do=edit&amp;user_id='.$id.'\', \'box\'); return false">Modifier</a> ] [ <a onclick="displayBox(\'requests/membres.php5?do=delete&amp;user_id='.$id.'&amp;user_name='.urlencode( $row->user_name ).'\', \'box\'); return false">Supprimer</a> ]</p>'.TXT_CRLF;
  101.                 }
  102.             }
  103.             else
  104.             {
  105.                 $totalCount = DbConnection::select( 'SELECT COUNT( `user_id` ) FROM `users` WHERE `user_id` <> 0 AND `users`.`user_membres` <> \'Sortants\' ;' , true );
  106.                 $length = 20;
  107.                 $pagesNum = ceil( $totalCount / $length );
  108.                 if( $start < 1 )
  109.                 {
  110.                     $start = 1;
  111.                 }
  112.                 if( $start > $pagesNum )
  113.                 {
  114.                     $start = $pagesNum;
  115.                 }
  116.                 $sqlStart = ( $start - 1 ) * $length;
  117.                 $sql = "SELECT `users`.`user_id`, `users`.`user_adress`, `users`.`user_tel1`, `users`.`user_tel2`, `users`.`user_mail`, `users`.`user_naissance`, `users`.`user_name` , `temp_reply`.`reply_count`
  118.                 FROM `users`
  119.                 LEFT JOIN ( SELECT `reply`.`user_id` , COUNT( `reply`.`user_id` ) AS `reply_count`
  120.                 FROM `reply` GROUP BY `reply`.`user_id` ) AS `temp_reply` ON `users`.`user_id` = `temp_reply`.`user_id`
  121.                 WHERE `users`.`user_id` <> 0 AND `users`.`user_membres` <> 'Sortants'
  122.                 ORDER BY `$sort` ".strtoupper($order)."
  123.                 LIMIT $sqlStart , $length;";
  124.                 $userCount = DbConnection::select( 'SELECT COUNT( `user_id` ) FROM `users` WHERE `user_id` <> 0 ;' , true );
  125.                 $executantsCount = DbConnection::select( 'SELECT COUNT( `user_id` ) FROM `users` WHERE `user_id` <> 0 AND `user_membres` = \'Exécutants\';' , true );
  126.                 $debutantsCount = DbConnection::select( 'SELECT COUNT( `user_id` ) FROM `users` WHERE `user_id` <> 0 AND `user_membres` = \'Débutants\';' , true );
  127.                 $eveilCount = DbConnection::select( 'SELECT COUNT( `user_id` ) FROM `users` WHERE `user_id` <> 0 AND `user_membres` = \'Eveil-musical\';' , true );
  128.                 $nonCount = DbConnection::select( 'SELECT COUNT( `user_id` ) FROM `users` WHERE `user_id` <> 0 AND `user_membres` = \'Non-musiciens\';' , true );
  129.                 $result = DbConnection::select( $sql );
  130.                 if( DbConnection::hasError() )
  131.                 {
  132.                     $error = DbConnection::getError();
  133.                 }
  134.                 if( $result )
  135.                 {
  136.                     $content = TXT_INDENT.TXT_INDENT.'<p class="print"><a href="print/membres.php5">Imprimer la liste des membres</a> | <a href="print/membres_birthday.php5">Imprimer les dates de naissance</a></p>';
  137.                     $content .= TXT_INDENT.TXT_INDENT.'<p id="pagination">Page&nbsp;: ';
  138.                     for( $i = 1 ; $i <= $pagesNum ; $i++)
  139.                     {
  140.                          if( $i == $start )
  141.                          {
  142.                             $content .= ' [ '.$i.' ] ';
  143.                          }
  144.                          else
  145.                          {
  146.                             $content .= " <a href=\"index.php5?cat=sorties&amp;page=membres&amp;view=$view&amp;sort=$sort&amp;order=$order&amp;start=$i\">".$i.'</a> ';
  147.                          }
  148.                     }
  149.                     $content .= '</p>'.TXT_CRLF;
  150.                     $content .= TXT_INDENT.TXT_INDENT.'<table id="liste-admin">'.TXT_CRLF;
  151.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'<thead>'.TXT_CRLF;
  152.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'<tr>'.TXT_CRLF;
  153.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th>Nom</th>'.TXT_CRLF;
  154.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th>Adresse</th>'.TXT_CRLF;
  155.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th>Téléphone 1</th>'.TXT_CRLF;
  156.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th>Téléphone 2</th>'.TXT_CRLF;
  157.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th>Courriel</th>'.TXT_CRLF;
  158.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th>Né(e) le</th>'.TXT_CRLF;
  159.                     /*$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th><a'.self::getFieldLinkAttributes( 'reply_count' , $sort , $order ).'>réponses</a></th>'.TXT_CRLF;*/
  160.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'</tr>'.TXT_CRLF;
  161.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'</thead>'.TXT_CRLF;
  162.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'<tfoot>'.TXT_CRLF;
  163.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'<tr>'.TXT_CRLF;
  164.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<th colspan="6">'.$totalCount.' Membres | '.$executantsCount.' Ex&eacute;cutants | '.$debutantsCount.' D&eacute;butants | '.$eveilCount.' Eveil musical | '.$nonCount.' Non musiciens</th>'.TXT_CRLF;
  165.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'</tr>'.TXT_CRLF;
  166.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'</tfoot>'.TXT_CRLF;
  167.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'<tbody>'.TXT_CRLF;
  168.                     while( $row = mysql_fetch_object( $result ) )
  169.                     {
  170.  
  171.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<tr>'.TXT_CRLF;
  172.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<td><a href="index.php5?cat=sorties&amp;page=membres&amp;view=detail&amp;id='.$row->user_id.'">'.$row->user_name.'</a></td>'.TXT_CRLF;
  173.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<td>'.nl2br( $row->user_adress ).'</td>'.TXT_CRLF;
  174.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<td>'.$row->user_tel1.'</td>'.TXT_CRLF;
  175.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<td>'.$row->user_tel2.'</td>'.TXT_CRLF;
  176.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<td>'.$row->user_mail.'</td>'.TXT_CRLF;
  177.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<td>'.birthDateFR( $row->user_naissance ).'</td>'.TXT_CRLF;
  178.                         /*$content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<td><a href="index.php5?cat=sorties&amp;page=reponses&amp;view=user&amp;id='.$row->user_id.'">'.$row->reply_count.'</a></td>'.TXT_CRLF;*/
  179.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'</tr>'.TXT_CRLF;
  180.                     }
  181.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.'</tbody>'.TXT_CRLF;
  182.                     $content .= TXT_INDENT.TXT_INDENT.'</table>'.TXT_CRLF;
  183.                 }
  184.                 else
  185.                 {
  186.                     $content = '<p>Aucun membre &agrave; afficher</p>';
  187.                 }
  188.             }
  189.             $content .= self::displayAddingBox();
  190.         }
  191.         elseif( $status === 'membre' )
  192.         {
  193.             $sql = "SELECT `questions`.`question_id` AS `id`, `questions`.`question_date`, DATE_FORMAT( `questions`.`question_date` , '%Hh%i' ) as `formated_time`, DATE_FORMAT( `questions`.`question_reply` , '%d/%m/%Y') as `formated_reply`, `questions`.`question_place`, `questions`.`question_object`, `questions`.`question_comment`, `reply`.`user_id`, `reply`.`question_id`, `reply`.`reply_value` FROM `questions` LEFT JOIN ( SELECT `reply`.`user_id`, `reply`.`question_id`, `reply`.`reply_value` FROM `reply` WHERE `reply`.`user_id` = '".$_SESSION['user_id']."' ) AS `reply` ON `questions`.`question_id` =  `reply`.`question_id` WHERE `questions`.`question_reply` >= NOW() GROUP BY `questions`.`question_id`";
  194.             
  195.             $result = DbConnection::select( $sql );
  196.             if( DbConnection::hasError() )
  197.             {
  198.                 $error = DbConnection::getError();
  199.             }
  200.             if( $result )
  201.             {
  202.                 $content = TXT_INDENT.TXT_INDENT.'<dl>'.TXT_CRLF;
  203.                 while( $row = mysql_fetch_object( $result ) )
  204.                 {
  205.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.$row->question_place.' le '.dateFR( $row->question_date ).' RDV Salle de musique '.$row->formated_time.TXT_CRLF;
  206.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p>'.$row->question_object.'</p>'.TXT_CRLF;
  207.                     if( !empty( $row->question_comment ) )
  208.                     {
  209.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p><em>'.$row->question_comment.'</em></p>'.TXT_CRLF;
  210.                     }
  211.                     if( $row->reply_value === null )
  212.                     {
  213.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<form method="post" action="index.php5?page=reply">'.TXT_CRLF;
  214.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p>réponse avant le '.$row->formated_reply.'</p>'.TXT_CRLF;
  215.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p>'.TXT_CRLF;
  216.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<select name="reply-value">'.TXT_CRLF;
  217.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="oui">Oui</option>'.TXT_CRLF;
  218.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="non">Non</option>'.TXT_CRLF;
  219.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="nsp">Ne sais pas</option>'.TXT_CRLF;
  220.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'</select>'.TXT_CRLF;
  221.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'</p>'.TXT_CRLF;
  222.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p><input type="hidden" name="do" value="insert" /><input type="hidden" name="id" value="'.$row->id.'" /><input type="submit" value="R&eacute;pondre" /></p>'.TXT_CRLF;
  223.                     }
  224.                     else
  225.                     {
  226.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<form method="post" action="index.php5?page=reply">'.TXT_CRLF;
  227.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p>réponse avant le '.$row->formated_reply.'</p>'.TXT_CRLF;
  228.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p>'.TXT_CRLF;
  229.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<select id="reply-value-'.$row->id.'" name="reply-value" disabled="disabled">'.TXT_CRLF;
  230.                         switch( true )
  231.                         {
  232.                             case( $row->reply_value === 'oui' ):
  233.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="oui" selected="selected">Oui</option>'.TXT_CRLF;
  234.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="non">Non</option>'.TXT_CRLF;
  235.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="nsp">Ne sais pas</option>'.TXT_CRLF;
  236.                             
  237.                                 break;
  238.                             case( $row->reply_value === 'non' ):
  239.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="oui">Oui</option>'.TXT_CRLF;
  240.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="non" selected="selected">Non</option>'.TXT_CRLF;
  241.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="nsp">Ne sais pas</option>'.TXT_CRLF;
  242.                             
  243.                                 break;
  244.                             case( $row->reply_value === 'nsp' ):
  245.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="oui">Oui</option>'.TXT_CRLF;
  246.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="non">Non</option>'.TXT_CRLF;
  247.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<option value="nsp" selected="selected">Ne sais pas</option>'.TXT_CRLF;
  248.                             
  249.                                 break;
  250.                         }
  251.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'</select>'.TXT_CRLF;
  252.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'</p>'.TXT_CRLF;
  253.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p><input type="hidden" name="do" value="update" /><input type="hidden" name="id" "value="'.$row->id.'" /><input type="submit" id="reply-submit-'.$row->id.'" value="R&eacute;pondre" disabled="disabled" /></p>'.TXT_CRLF;
  254.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p id="reply-modify-'.$row->id.'"><input type="button" onclick="enableReplyButtons('.$row->id.');" value="modifier" /></p>'.TXT_CRLF;
  255.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<p id="reply-cancel-'.$row->id.'" class="reply-cancel"><input type="button" onclick="disableReplyButtons('.$row->id.');" value="annuler" /></p>'.TXT_CRLF;
  256.                         $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'<script type="text/javascript" src="../resources/js/toggleReplyButtons.js"></script>'.TXT_CRLF;
  257.                     }
  258.                     $content .= TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.'</form>'.TXT_CRLF;
  259.                 }
  260.                 $content .= TXT_INDENT.TXT_INDENT.'</dl>'.TXT_CRLF;
  261.             }
  262.             else
  263.             {
  264.                 $content = TXT_INDENT.TXT_INDENT.'<p>Il n\'y a pas de sortie &agrave; afficher.</p>'.TXT_CRLF;
  265.             }
  266.         }
  267.         else
  268.         {
  269.             $sql = "SELECT  `questions`.`question_date`, DATE_FORMAT( `questions`.`question_date` , '%Hh%i' ) as `formated_time`, `question_place`, `question_object`, `question_comment` FROM `questions` WHERE `question_date` > NOW()";
  270.             $result = DbConnection::select( $sql );
  271.             if( DbConnection::hasError() === true )
  272.             {
  273.                 $error = DbConnection::getError();
  274.             }
  275.             if( $result )
  276.             {
  277.                 $content = TXT_INDENT.TXT_INDENT.'<ul id="questions">'.TXT_CRLF;
  278.                 while( $row = mysql_fetch_object( $result ) )
  279.                 {
  280.                     $content .= TXT_INDENT.TXT_INDENT.'<li><span class="questions-date">'.dateFR( $row->question_date ).'</span><span class="questions-time">RDV Salle de musique '.$row->formated_time.'</span><span class="questions-place">'.$row->question_place.'</span><span class="questions-object">'.$row->question_object.'</span>';
  281.                     if( empty( $row->question_comment ) )
  282.                     {
  283.                         $content .= '</li>'.TXT_CRLF;
  284.                     }
  285.                     else
  286.                     {
  287.                         $content .= '<span class="questions-comment">'.$row->question_comment.'</span></li>'.TXT_CRLF;
  288.                     }
  289.                 }
  290.                 $content .= TXT_INDENT.TXT_INDENT.'</ul>'.TXT_CRLF;
  291.             }
  292.             else
  293.             {
  294.                 $content = TXT_INDENT.TXT_INDENT.'<p>Il n\'y a pas de sortie &agrave; afficher.</p>'.TXT_CRLF;
  295.             }
  296.         }
  297.         return $content;
  298.     }
  299.     
  300.     static function displayBureau()
  301.     {
  302.         $sql = "SELECT `users`.`user_name`, `users`.`user_bureau`
  303.         FROM `users`  
  304.         WHERE `user_bureau` <> ''
  305.         ORDER BY `users`.`user_bureau`";
  306.         $result = DbConnection::select( $sql );
  307.         if( DbConnection::hasError() )
  308.         {
  309.             $error = DbConnection::getError();
  310.         }
  311.         if( $result )
  312.         {
  313.             echo TXT_INDENT.TXT_INDENT , '<dl id="bureau">' , TXT_CRLF;
  314.             while( $row = mysql_fetch_object( $result ) )
  315.             {
  316.                 echo TXT_INDENT.TXT_INDENT , '<dt>' , $row->user_bureau , ' </dt>' , TXT_CRLF;
  317.                 echo TXT_INDENT.TXT_INDENT , '<dd>' , $row->user_name , ' </dd>' , TXT_CRLF;
  318.             }
  319.             echo TXT_INDENT.TXT_INDENT , '</dl>' , TXT_CRLF;
  320.         }
  321.     }
  322.     
  323.     static function displayComite()
  324.     {
  325.         $sql = "SELECT `users`.`user_name`, `users`.`user_responsable`
  326.         FROM `users`
  327.         WHERE `user_responsable` <> ''
  328.         ORDER BY `users`.`user_responsable`";
  329.         $result = DbConnection::select( $sql );
  330.         if( DbConnection::hasError() )
  331.         {
  332.             $error = DbConnection::getError();
  333.         }
  334.         if( $result )
  335.         {
  336.             echo TXT_INDENT.TXT_INDENT , '<dl id="comite">' , TXT_CRLF;
  337.             while( $row = mysql_fetch_object( $result ) )
  338.             {
  339.                 echo TXT_INDENT.TXT_INDENT , '<dt>' , $row->user_responsable , ' </dt>' , TXT_CRLF;
  340.                 echo TXT_INDENT.TXT_INDENT , '<dd>' , $row->user_name , ' </dd>' , TXT_CRLF;
  341.             }
  342.             echo TXT_INDENT.TXT_INDENT , '</dl>' , TXT_CRLF;
  343.         }
  344.     }
  345.     
  346.     static function displayExecutants()
  347.     {
  348.         if( isset( $_GET['sort'] ) && !empty( $_GET['sort'] ) )
  349.         {
  350.             $sort = $_GET['sort'];
  351.             if( !in_array( $sort , array ( 'user_name' , 'user_admission' , 'user_demission' ) ) )
  352.             {
  353.                 $sort = 'user_name';
  354.             }
  355.         }
  356.         else
  357.         {
  358.             $sort = 'user_name';
  359.         }
  360.         if( isset( $_GET['order'] ) && !empty( $_GET['order'] ) )
  361.         {
  362.             $order = $_GET['order'];
  363.             if( !in_array( $order , array ( 'asc' , 'desc' ) ) )
  364.             {
  365.                 $order = 'asc';
  366.             }
  367.         }
  368.         else
  369.         {
  370.             $order = 'asc';
  371.         }
  372.         $sql = "SELECT `users`.`user_name`, `users`.`user_membres`, `users`.`user_admission`, `users`.`user_demission`  
  373.         FROM `users`  
  374.         WHERE `users`.`user_id` <> 0 AND  (`users`.`user_membres` = 'Exécutants' OR  `users`.`user_membres` = 'Sortants')  
  375.         ORDER BY `$sort` ".strtoupper($order);
  376.         $result = DbConnection::select( $sql );
  377.         if( DbConnection::hasError() )
  378.         {
  379.             $error = DbConnection::getError();
  380.         }
  381.         if( $result )
  382.         {
  383.             echo TXT_INDENT.TXT_INDENT , '<table id="executants">' , TXT_CRLF;
  384.             echo TXT_INDENT.TXT_INDENT.TXT_INDENT , '<thead>' , TXT_CRLF;
  385.             echo TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT , '<tr>' , TXT_CRLF;
  386.             echo TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT , '<th><a'.self::getFieldLinkAttributes( 'user_name' , $sort , $order , 'index.php5?cat=musiciens&amp;page=bureau' ).'>Nom</a></th>' , TXT_CRLF;
  387.             echo TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT , '<th><a'.self::getFieldLinkAttributes( 'user_admission' , $sort , $order , 'index.php5?cat=musiciens&amp;page=bureau' ).'>Admission</a></th>' , TXT_CRLF;
  388.             echo TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT , '<th><a'.self::getFieldLinkAttributes( 'user_demission' , $sort , $order , 'index.php5?cat=musiciens&amp;page=bureau' ).'>Démission</a></th>' , TXT_CRLF;
  389.             echo TXT_INDENT.TXT_INDENT.TXT_INDENT.TXT_INDENT , '</tr>' , TXT_CRLF;
  390.             echo TXT_INDENT.TXT_INDENT , '</thead>' , TXT_CRLF;
  391.             echo TXT_INDENT.TXT_INDENT , '</body>' , TXT_CRLF;
  392.             while( $row = mysql_fetch_object( $result ) )
  393.             {
  394.                 $entree = ( $row->user_admission === '0000-00-00' ) ? '' : shortDateFR( $row->user_admission );
  395.                 $sortie = ( $row->user_demission === '0000-00-00' ) ? '' : shortDateFR( $row->user_demission );
  396.                 echo TXT_INDENT.TXT_INDENT , '<tr><td>' , $row->user_name , '</td><td>' , $entree , '</td><td>', $sortie , '</td></tr>' , TXT_CRLF;
  397.             }
  398.             echo TXT_INDENT.TXT_INDENT , '</tbody>' , TXT_CRLF;
  399.             echo TXT_INDENT.TXT_INDENT , '</table>' , TXT_CRLF;
  400.         }
  401.     }
  402.  
  403.     static function displayAddingBox()
  404.     {
  405.     ?>
  406.     <div id="box">
  407.     <form action="index.php5?cat=sorties&amp;page=membres" method="post" >
  408.         <fieldset>
  409.             <legend>Ajouter un membre</legend>
  410.         <p>
  411.             <label for="add-nom">Nom :</label>
  412.             <input type="text" name="nom" id="add-nom" />
  413.         </p>
  414.         <p>
  415.             <label for="add-adress">Adresse :</label>
  416.             <textarea id="add-adress" name="adress"></textarea>
  417.         </p>
  418.         <p>
  419.             <label for="add-tel1">Téléphone 1 :</label>
  420.             <input type="text" name="tel1" id="add-tel1" />
  421.         </p>
  422.         <p>
  423.             <label for="add-tel2">Téléphone 2 :</label>
  424.             <input type="text" name="tel2" id="add-tel2" />
  425.         </p>
  426.         <p>
  427.             <label for="add-mail">Courriel :</label>
  428.             <input type="text" name="mail" id="add-mail" />
  429.         </p>
  430.         <p>
  431.             <label for="add-pupitres">Pupitre :</label>
  432.             <?php
  433.             //menu déroulant pour le type de pupitres
  434.             //requête
  435.             $sql="show columns from  users like 'user_pupitres'";
  436.             $result = DbConnection::select( $sql );
  437.             if( DbConnection::hasError() )
  438.             {
  439.                 $error = DbConnection::getError();
  440.             }
  441.             if( $result )
  442.             {
  443.                 //on récupère la colonne 'Type' dans le résultat $result de la requete $sql
  444.                 $type=mysql_result($result,0,'Type');
  445.                 //ce qui donne un string du type : set('blabla','blabla',...)
  446.                 //il faut donc enlever le début et la fin puis utiliser split pour récupérer chaque champ
  447.                 $type=substr($type,5,strlen($type)-5-2);
  448.                 $resp=split("','",$type);
  449.                 //creation du select avec toutes les options correspondant à chaque champ du tableau $resp
  450.                 echo "<select multiple name='pupitres' id='add-pupitres'>";
  451.                 echo "<option selected value='-1'>--liste pupitres--</option>";
  452.                 foreach( $resp as $row )
  453.                 {
  454.                     echo "<option value=$row>$row</option>";
  455.                 }
  456.                 echo "</select>";
  457.             }
  458.             ?>
  459.         </p>
  460.         <p>
  461.             <label for="add-membres">Membre :</label>
  462.             <?php
  463.             //menu déroulant pour le type de membres
  464.             $sql="show columns from  users like 'user_membres'";
  465.             $result = DbConnection::select( $sql );
  466.             if( DbConnection::hasError() )
  467.             {
  468.                 $error = DbConnection::getError();
  469.             }
  470.             if( $result )
  471.             {
  472.                 $type=mysql_result($result,0,'Type');
  473.                 $type=substr($type,5,strlen($type)-5-2);
  474.                 $resp=split("','",$type);
  475.                 echo "<select multiple name='membres' id='add-membres'>";
  476.                 echo "<option selected value='-1'>--liste membres--</option>";
  477.                 foreach( $resp as $row )
  478.                 {
  479.                     echo "<option value=$row>$row</option>";
  480.                 }
  481.                 echo "</select>";
  482.             }
  483.             ?>
  484.         </p>
  485.         <p>
  486.             <label for="add-admission">Admission :</label>
  487.             <input onclick="ds_sh(this);" type="text" name="admission" id="add-admission" />
  488.         </p>
  489.         <p>
  490.             <label for="add-demission">Démission :</label>
  491.             <input onclick="ds_sh(this);" type="text" name="demission" id="add-demission" />
  492.         </p>
  493.         <p>
  494.             <label for="add-naissance">Né(e) le :</label>
  495.             <input onclick="ds_sh(this);" type="text" name="naissance" id="add-naissance" />
  496.         </p>
  497.         <p>
  498.             <label for="add-bureau">Bureau :</label>
  499.             <?php
  500.             $sql="show columns from  users like 'user_bureau'";
  501.             $result = DbConnection::select( $sql );
  502.             if( DbConnection::hasError() )
  503.             {
  504.                 $error = DbConnection::getError();
  505.             }
  506.             if( $result )
  507.             {
  508.                 $type=mysql_result($result,0,'Type');
  509.                 $type=substr($type,5,strlen($type)-5-2);
  510.                 $resp=split("','",$type);
  511.                 echo "<select multiple name='bureau' id='add-bureau'>";
  512.                 echo "<option selected value='-1'>--liste du bureau--</option>";
  513.                 foreach( $resp as $row )
  514.                 {
  515.                     echo "<option value=$row>$row</option>";
  516.                 }
  517.                 echo "</select>";
  518.             }
  519.             ?>
  520.         </p>
  521.         <p>
  522.             <label for="add-responsable">Responsable :</label>
  523.             <?php
  524.             //Menu déroulant pour la liste des responsabilités
  525.             $sql="show columns from  users like 'user_responsable'";
  526.             $result = DbConnection::select( $sql );
  527.             
  528.             if( DbConnection::hasError() )
  529.             {
  530.                 $error = DbConnection::getError();
  531.             }
  532.             if( $result )
  533.             {
  534.                 $type=mysql_result($result,0,'Type');
  535.                 $type=substr($type,5,strlen($type)-5-2);
  536.                 $resp=split("','",$type);
  537.                 
  538.                 //TODO multiple
  539.                 echo "<select multiple name='responsable'id='add-responsable'>";
  540.                 echo "<option selected value='-1'>--liste des responsabilites--</option>";
  541.                 
  542.                 /*echo "<option value = $resp[0]> $resp[0] </option>";
  543.                 echo "<option value = $resp[1]> $resp[1] </option>";
  544.                 echo "<option value = $resp[count($resp)-1]> $resp[count($resp)-1] </option>";*/
  545.                 
  546.                 foreach( $resp as $row )
  547.     {
  548.         echo "<option value=$row>$row</option>";
  549.     }
  550.  
  551.                 
  552.                 /*for ($i=0; $i<count($resp); $i++) {
  553.                     echo "<option value = $resp[i]> '$resp[i]' </option>";
  554.                 }*/
  555.                 
  556.                 /*while($row = mysql_fetch_array($resp))
  557.                 {
  558.                     echo "<option value=$data[0]>$data[0]</option>";
  559.                 }
  560. */                echo "</select>";
  561.             }
  562.             ?>
  563.         </p>
  564.         <p>
  565.             <input type="hidden" name="do" value="add" />
  566.             <input type="reset" value="Effacer" />
  567.             <input type="submit" value="Soumettre" />
  568.         </p>
  569.         </fieldset>
  570.     </form>
  571.     </div>
  572.     <?php //return $box;
  573.  
  574.     }
  575.  
  576.     static function addMembre()
  577.     {
  578.         $errors = array();
  579.         if( isset( $_POST['nom'] ) )
  580.         {
  581.             $input['nom'] = $_POST['nom'];
  582.         }
  583.         else
  584.         {
  585.             $errors[] = 'Il faut saisir une valeur pour le nom.';
  586.         }
  587.         if( isset( $_POST['mail'] ) )
  588.         {
  589.             $input['mail'] = $_POST['mail'];
  590.         }
  591.         else
  592.         {
  593.             $input['mail'] = '';
  594.         }
  595.         if( isset( $_POST['adress'] ) )
  596.         {
  597.             $input['adress'] = $_POST['adress'];
  598.         }
  599.         else
  600.         {
  601.             $input['adress'] = '';
  602.         }
  603.         if( isset( $_POST['tel1'] ) )
  604.         {
  605.             $input['tel1'] = $_POST['tel1'];
  606.         }
  607.         else
  608.         {
  609.             $input['tel1'] = '';
  610.         }
  611.         if( isset( $_POST['tel2'] ) )
  612.         {
  613.             $input['tel2'] = $_POST['tel2'];
  614.         }
  615.         else
  616.         {
  617.             $input['tel2'] = '';
  618.         }
  619.         if( isset( $_POST['pupitres'] ) )
  620.         {
  621.             $input['pupitres'] = $_POST['pupitres'];
  622.         }
  623.         else
  624.         {
  625.             $input['pupitres'] = '';
  626.         }
  627.         if( isset( $_POST['membres'] ) )
  628.         {
  629.             $input['membres'] = $_POST['membres'];
  630.         }
  631.         else
  632.         {
  633.             $input['membres'] = '';
  634.         }
  635.         if( isset( $_POST['admission'] ) )
  636.         {
  637.             $input['admission'] = $_POST['admission'];
  638.         }
  639.         else
  640.         {
  641.             $input['admission'] = '';
  642.         }
  643.         if( isset( $_POST['demission'] ) )
  644.         {
  645.             $input['demission'] = $_POST['demission'];
  646.         }
  647.         else
  648.         {
  649.             $input['demission'] = '';
  650.         }
  651.         if( isset( $_POST['naissance'] ) )
  652.         {
  653.             $input['naissance'] = $_POST['naissance'];
  654.         }
  655.         else
  656.         {
  657.             $input['naissance'] = '';
  658.         }
  659.         if( isset( $_POST['bureau'] ) )
  660.         {
  661.             $input['bureau'] = $_POST['bureau'];
  662.         }
  663.         else
  664.         {
  665.             $input['bureau'] = '';
  666.         }
  667.         if( isset( $_POST['responsable'] ) )
  668.         {
  669.             $input['responsable'] = $_POST['responsable'];
  670.         }
  671.         else
  672.         {
  673.             $input['responsable'] = '';
  674.         }
  675.         if( count( $errors ) > 0 )
  676.         {
  677.             return implode( '<br />' , $errors );
  678.         }
  679.         $input['pswd'] = self::buildPassword();
  680.         $result = dbConnection::insert("INSERT INTO `users` ( `user_id` , `user_name` , `user_adress` , `user_tel1` , `user_tel2` , `user_mail` , `user_pupitres` , `user_membres` , `user_password` , `user_admission` , `user_demission` , `user_naissance` , `user_bureau` , `user_responsable` ) VALUES ( NULL , '".$input['nom']."', '".$input['adress']."', '".$input['tel1']."', '".$input['tel2']."', '".$input['mail']."', '".$input['pupitres']."', '".$input['membres']."', PASSWORD( '".$input['pswd']."' ), '".dateSQL( $input['admission'] )."', '".dateSQL( $input['demission'] )."', '".dateSQL( $input['naissance'] )."', '".$input['bureau']."', '".$input['responsable']."' );" );
  681.         return $result;
  682.     }
  683.  
  684.     static function updateMembre( $id )
  685.     {
  686.         $errors = array();
  687.         if( isset( $_POST['nom'] ) )
  688.         {
  689.             $input['nom'] = $_POST['nom'];
  690.         }
  691.         else
  692.         {
  693.             $errors[] = 'Il faut saisir une valeur pour le nom.';
  694.         }
  695.         if( isset( $_POST['mail'] ) )
  696.         {
  697.             $input['mail'] = $_POST['mail'];
  698.         }
  699.         else
  700.         {
  701.             $input['mail'] = '';
  702.         }
  703.         if( isset( $_POST['adress'] ) )
  704.         {
  705.             $input['adress'] = $_POST['adress'];
  706.         }
  707.         else
  708.         {
  709.             $input['adress'] = '';
  710.         }
  711.         if( isset( $_POST['tel1'] ) )
  712.         {
  713.             $input['tel1'] = $_POST['tel1'];
  714.         }
  715.         else
  716.         {
  717.             $input['tel1'] = '';
  718.         }
  719.         if( isset( $_POST['tel2'] ) )
  720.         {
  721.             $input['tel2'] = $_POST['tel2'];
  722.         }
  723.         else
  724.         {
  725.             $input['tel2'] = '';
  726.         }
  727.         if( isset( $_POST['pupitres'] ) )
  728.         {
  729.             $input['pupitres'] = $_POST['pupitres'];
  730.         }
  731.         else
  732.         {
  733.             $input['pupitres'] = '';
  734.         }
  735.         if( isset( $_POST['membres'] ) )
  736.         {
  737.             $input['membres'] = $_POST['membres'];
  738.         }
  739.         else
  740.         {
  741.             $input['membres'] = '';
  742.         }
  743.         if( isset( $_POST['admission'] ) )
  744.         {
  745.             $input['admission'] = $_POST['admission'];
  746.         }
  747.         else
  748.         {
  749.             $input['admission'] = '';
  750.         }
  751.         if( isset( $_POST['demission'] ) )
  752.         {
  753.             $input['demission'] = $_POST['demission'];
  754.         }
  755.         else
  756.         {
  757.             $input['demission'] = '';
  758.         }
  759.         if( isset( $_POST['naissance'] ) )
  760.         {
  761.             $input['naissance'] = $_POST['naissance'];
  762.         }
  763.         else
  764.         {
  765.             $input['naissance'] = '';
  766.         }
  767.         if( isset( $_POST['bureau'] ) )
  768.         {
  769.             $input['bureau'] = $_POST['bureau'];
  770.         }
  771.         else
  772.         {
  773.             $input['bureau'] = '';
  774.         }
  775.         if( isset( $_POST['responsable'] ) )
  776.         {
  777.             $input['responsable'] = $_POST['responsable'];
  778.         }
  779.         else
  780.         {
  781.             $input['responsable'] = '';
  782.         }
  783.         if( count( $errors ) > 0 )
  784.         {
  785.             return implode( '<br />' , $errors );
  786.         }
  787.         $input['pswd'] = self::buildPassword();
  788.         //UPDATE `users` SET `user_tel1` = '9876543210' WHERE `user_id` =64 LIMIT 1 ;
  789.         $result = dbConnection::query( "UPDATE `users` SET `user_name` = '".$input['nom']."' , `user_adress` = '".$input['adress']."' , `user_tel1` = '".$input['tel1']."' , `user_tel2` = '".$input['tel2']."' , `user_mail` = '".$input['mail']."' , `user_pupitres` = '".$input['pupitres']."' , `user_membres` = '".$input['membres']."' , `user_admission` = '".dateSQL( $input['admission'] )."' , `user_demission` = '".dateSQL( $input['demission'] )."' , `user_naissance` = '".dateSQL( $input['naissance'] )."' , `user_bureau` = '".$input['bureau']."' , `user_responsable` = '".$input['responsable']."'WHERE `user_id` = ".$id.' LIMIT 1' );
  790.         return $result;
  791.     }
  792.     
  793.     static function deleteMembre( $id )
  794.     {    
  795.         $id = mysql_real_escape_string( $id , DbConnection::getLink() );
  796.         $sql = "DELETE FROM `users` WHERE `users`.`user_id` = $id LIMIT 1;";
  797.         return dbConnection::query( $sql );
  798.     }
  799.     
  800.     static function buildPassword()
  801.     {
  802.         $letters = array();
  803.         for( $i = 0 ; $i < 6 ; $i++ )
  804.         {
  805.             $letters[] = chr( rand( 97 , 122 ) );
  806.         }
  807.         return implode( '' , $letters );
  808.     }
  809.     
  810.     static function deleteQuestion( $id )
  811.     {    
  812.         $id = mysql_real_escape_string( $id , DbConnection::getLink() );
  813.         $sql = "DELETE FROM `questions` WHERE `questions`.`question_id` = $id LIMIT 1;";
  814.         return dbConnection::query( $sql );
  815.     }
  816.     
  817.     static function updateQuestion( $id )
  818.     {
  819.         if( isset( $_POST['date'] ) && !empty( $_POST['date'] ) )
  820.         {
  821.             $input['date'] = $_POST['date'];
  822.             if( !preg_match( '`(\d{1,2})/(\d{1,2})/(\d{4})`' , $input['date'] ) )
  823.             {  
  824.                 $errors[] = 'La date saisie pour la sortie est incorrecte.';
  825.             }
  826.             elseif( isset( $_POST['heure'] ) && !empty( $_POST['heure'] ) && isset( $_POST['minute'] ) && !empty( $_POST['minute'] ) )
  827.             {
  828.                 list( $day , $month , $year ) = explode( '/' , $input['date'] );
  829.                 $hour = (int) $_POST['heure'];
  830.                 $minut = (int) $_POST['minute'];
  831.                 $month = (int) $month;
  832.                 $day = (int) $day;
  833.                 $year = (int) $year;
  834.                 if( !mktime( $hour , $minut , 00 , $month , $day , $year ) )
  835.                 {
  836.                     $errors[] = 'L\'heure saisie pour la sortie est incorrecte.';
  837.                 }
  838.                 else
  839.                 {
  840.                     $hour = str_pad( $hour , 2, '0' , STR_PAD_LEFT );
  841.                     $minut = str_pad( $minut , 2, '0' , STR_PAD_LEFT );
  842.                     $month = str_pad( $month , 2, '0' , STR_PAD_LEFT );
  843.                     $day = str_pad( $day , 2, '0' , STR_PAD_LEFT );
  844.                     $input['date'] = $year.$month.$day.$hour.$minut.'00';
  845.                 }
  846.             }
  847.             else
  848.             {
  849.                 $errors[] = 'Il faut saisir une valeur pour l\'heure de la sortie.';
  850.             }
  851.         }
  852.         else
  853.         {
  854.             $errors[] = 'Il faut saisir une valeur pour la date de la sortie.';
  855.         }
  856.         if( isset( $_POST['reponse'] ) && !empty( $_POST['reponse'] ) )
  857.         {
  858.             $input['reponse'] = $_POST['reponse'];
  859.             if( !preg_match( '`(\d{1,2})/(\d{1,2})/(\d{4})`' , $input['reponse'] ) )
  860.             {  
  861.                 $errors[] = 'La date saisie pour la réponse est incorrecte.';
  862.             }
  863.             else
  864.             {
  865.                 list( $day , $month , $year ) = explode( '/' , $input['reponse'] );
  866.                 $month = str_pad( $month , 2, '0' , STR_PAD_LEFT );
  867.                 $day = str_pad( $day , 2, '0' , STR_PAD_LEFT );
  868.                 $input['reponse'] = $year.$month.$day.'235959';
  869.             }
  870.         }
  871.         else
  872.         {
  873.             $errors[] = 'Il faut saisir une valeur pour la date de réponse.';
  874.         }
  875.         if( isset( $_POST['lieu'] ) && !empty( $_POST['lieu'] ) )
  876.         {
  877.             $input['lieu'] =  mysql_real_escape_string( $_POST['lieu'] , DbConnection::getLink() );
  878.         }
  879.         else
  880.         {
  881.             $errors[] = 'Il faut saisir une valeur pour le lieu de la sortie.';
  882.         }
  883.         if( isset( $_POST['objet'] ) && !empty( $_POST['objet'] ) )
  884.         {
  885.             $input['objet'] =  mysql_real_escape_string( $_POST['objet'] , DbConnection::getLink() );
  886.         }
  887.         else
  888.         {
  889.             $errors[] = 'Il faut saisir une valeur pour l\'objet de la sortie.';
  890.         }
  891.         if( isset( $_POST['commentaire'] ) )
  892.         {
  893.             $input['commentaire'] =  mysql_real_escape_string( $_POST['commentaire'] , DbConnection::getLink() );
  894.         }
  895.         else
  896.         {
  897.             $input['commentaire'] = '';
  898.         }
  899.         if( count( $errors ) > 0 )
  900.         {
  901.             return implode( '<br />' , $errors );
  902.         }
  903.         return dbConnection::query("UPDATE `questions` SET `question_date` = '{$input['date']}', `question_reply` = '{$input['reponse']}', `question_place` = '{$input['lieu']}', `question_object` = '{$input['objet']}', `question_comment` = '{$input['commentaire']}' WHERE `questions`.`question_id` = $id LIMIT 1 ;" );
  904.     }
  905.     
  906.     static function getOne( $id , $withDetails = false )
  907.     {
  908.         if( $withDetails )
  909.         {
  910.             $sql = "SELECT `user_id`, `user_mail`, `user_name`, `user_adress`, `user_tel1`, `user_tel2`, `user_password`, `user_pupitres`, `user_membres`, `user_admission`, `user_demission`, `user_naissance`, `user_bureau`, `user_responsable` FROM `users` WHERE `user_id` ='$id' LIMIT 1";
  911.         }
  912.         else
  913.         {
  914.             $sql = "SELECT `user_id`, `user_mail`, `user_name`, `user_adress`, `user_tel1`, `user_tel2`, `user_password`, `user_pupitres`, `user_membres`, `user_admission`, `user_demission`, `user_naissance`, `user_bureau`, `user_responsable` FROM `users` WHERE `user_id` ='$id' LIMIT 1";
  915.         }
  916.         $result = DbConnection::select( $sql );
  917.         if( $result )
  918.         {
  919.             return mysql_fetch_object( $result );
  920.         }
  921.         else
  922.         {
  923.             return false;
  924.         }
  925.     }
  926.  
  927.     private static function getFieldLinkAttributes( $field , $sort , $order , $page = 'index.php5?cat=sorties&amp;page=membres' )
  928.     {
  929.         if( $field === $sort )
  930.         {
  931.             if( $order === 'asc' )
  932.             {
  933.                 $invertOrder = 'desc';
  934.             }
  935.             else
  936.             {
  937.                 $invertOrder = 'asc';
  938.             }
  939.             $attributes = " href=\"$page&amp;sort=$field&amp;order=$invertOrder\" class=\"sort-$order\"";
  940.         }
  941.         else
  942.         {
  943.             $attributes = " href=\"$page&amp;sort=$field&amp;order=$order\"";
  944.         }
  945.         return $attributes;
  946.     }
  947. }
  948. ?>

n°1760174
l0g4n
Expert en tout :o
Posté le 16-07-2008 à 11:29:31  profilanswer
 

Par contre, sauf si on te le demande explicitement, ne remet JAMAIS un code de près de 1000 lignes sur un forum, au delà d'une 30aine de lignes, élague l'inutile.


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  Requète sur plusieurs lignes

 

Sujets relatifs
Plusieurs Count et Group By sur une table[VBA/Excel]Filtre Auto et copie des lignes résultantes
requete à problème[SQL] problème requête
Changer balise dans plusieurs fichiersProbleme requete sql vba
fpdf : générer plusieurs pdf en même tempsTélécharger en une fois plusieurs fichiers...
[MySQL]Execution d'une sous requete qui retourne plusieurs lignesmysql : requête entre plusieurs lignes N, N-1, N-2, etc...
Plus de sujets relatifs à : Requète sur plusieurs lignes


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR