IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

affichage "lignes vides"


Sujet :

PHP & Base de données

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    223
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2008
    Messages : 223
    Par défaut affichage "lignes vides"
    Bonjour,
    Je ne sais pas si c'est ici que je dois poster, je ne sais pas si c'est un problème de php que je rencontre (ce n'est pas moi qui ai fait le code)...
    Sur un formulaire, j'ai plusieurs textarea comme ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <textarea name="texte1" onBlur="this.value=bannir(this.value)" id="idTextarea" cols="80" rows="7" class="fenetrecomm"><?php echo htmlentities($row_Recordset1['texte1'], ENT_COMPAT, 'iso-8859-1'); ?></textarea>
    que j'affiche ensuite comme ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <td colspan="3" align="left"><?php echo nl2br ($row_Recordset1['texte1']); ?><br /></td>
    J'ai une page modif.php à partir de laquelle je peux modifier tous les textarea d'un même enregistrement.
    Si, à la fin du texte que j'écris, je génère un ou deux paragraphes (ou faut-il dire des lignes vides ?) en tapant sur Entrée de mon clavier, je vois bien l'espace à l'affichage, et il reste là ; en revanche, si je le fais au début de mon texte (pour laisser de l'espace au-dessus), je le vois bien à l'affichage, mais à chaque fois que je vais utiliser la page modif.php par la suite, il y a une ligne vide qui disparaît.
    Plus concrètement : je crée trois lignes vides au début du texte1, je les vois ensuite sur la page d'affichage. Puis je reviens sur modif.php pour modifier par exemple texte2, j'enregistre, et sur la page d'affichage les trois lignes du texte1 sont devenues deux ! Et si je me sers encore une fois de modif.php, des deux lignes il n'en reste plus qu'une !
    Ce qui m'étonne le plus, c'est qu'en allant voir dans phpmyadmin, les 3 lignes vides que j'ai faites sont toujours bien là ! Donc je crois que c'est au moment de l'enregistrement de modif.php que les lignes se barrent.
    Pouvez-vous me dire de quoi il s'agit à votre avis svp ? Merci d'avance !

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Par défaut
    Sans voir le code il est difficile de te répondre.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    223
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2008
    Messages : 223
    Par défaut
    évidemment ...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    <?php 
    session_start();
    require_once('../../../../Connections/conncz.php');
    if(!isset($_SESSION['ID_pub']) && $_SESSION['ID_pub'] == "")
    {       
        //echo "ici 1";
        $_SESSION['pageToRedirect'] = 'modif.php';
        $_SESSION['erreur'] = "Vous ne pouvez pas accéder à ce fichier.";
        $errorGoTo = "identification-maj.php";
        if (isset($_SERVER['QUERY_STRING'])) {
          //$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
          $errorGoTo .= $_SERVER['QUERY_STRING'];
        }
        header(sprintf("Location: %s", $errorGoTo));     
    }
    else
    {
      if(isset($_POST['test']) && $_POST['test'] <> "")
      {
        //echo "ici 2";
        if (!function_exists("GetSQLValueString")) {
        function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
        {
          if (PHP_VERSION < 6) {
            $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
          }
     
          $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
     
          switch ($theType) {
            case "text":
              $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
              break;    
            case "long":
            case "int":
              $theValue = ($theValue != "") ? intval($theValue) : "NULL";
              break;
            case "double":
              $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
              break;
            case "date":
              $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
              break;
            case "defined":
              $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
              break;
          }
          return $theValue;
        }
        }
     
        $editFormAction = $_SERVER['PHP_SELF'];
        if (isset($_SERVER['QUERY_STRING'])) {
          $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
        }
     
        if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
          $updateSQL = sprintf("UPDATE pub SET slogan=%s, texte3=%s, texte1=%s, texte5=%s, texte2=%s, texte4=%s, jour=%s WHERE ID_pub=%s",
     
                               GetSQLValueString($_POST['slogan'], "text"),
                               GetSQLValueString($_POST['texte3'], "text"),
                               GetSQLValueString($_POST['texte1'], "text"),
                               GetSQLValueString($_POST['texte5'], "text"),
     
                               GetSQLValueString($_POST['texte2'], "text"),
     
                               GetSQLValueString($_POST['texte4'], "text"),
    						                //GetSQLValueString($_POST['img1'], "text"),
                               GetSQLValueString($_POST['jour'], "date"),
                               GetSQLValueString($_POST['ID_pub'], "int"));
     
          mysql_select_db($database_conncz, $conncz);
          $Result1 = mysql_query($updateSQL, $conncz) or die(mysql_error());
     
          if(isset($_POST['ID_pub']))
          {
              $_SESSION['pubID'] =  $_POST['ID_pub'];
          }
          else
          {
              $_SESSION['pubID'] =  "erreur";            
          }
          $updateGoTo = "confirmation.php";
          if (isset($_SERVER['QUERY_STRING'])) {
            $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
            $updateGoTo .= $_SERVER['QUERY_STRING'];
          }
          header(sprintf("Location: %s", $updateGoTo));
        }
      }
      else
      {
        if($_SESSION['ID_pub'] == "")
        {
              $_SESSION['erreur'] = "Vous ne pouvez pas accéder à ce fichier.";
              $errorGoTo = "identification-maj.php";
              if (isset($_SERVER['QUERY_STRING'])) {
                //$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
                $errorGoTo .= $_SERVER['QUERY_STRING'];
              }
              header(sprintf("Location: %s", $errorGoTo));
        }
        else
        {
            //echo "ici 3";
       $colname_Recordset1 = "-1";
        if (isset($_GET['ID_pub'])) {
          $colname_Recordset1 = $_GET['ID_pub'];
        }
     
        $idPub =   $_SESSION['ID_pub'];
        //$_SESSION['ID_pub'] = "";
     
        mysql_select_db($database_conncz, $conncz);
        //$query_Recordset1 = sprintf("SELECT * FROM pub WHERE ID_pub = %s", GetSQLValueString($colname_Recordset1, "int"));
        $query_Recordset1 = "SELECT * FROM pub WHERE ID_pub = ". $idPub;
        $Recordset1 = mysql_query($query_Recordset1, $conncz) or die(mysql_error());
        $row_Recordset1 = mysql_fetch_assoc($Recordset1);
        $totalRows_Recordset1 = mysql_num_rows($Recordset1);$colname_Recordset1 = "-1";
          if (isset($_POST['nom'])) {
            $colname_Recordset1 = $_POST['nom'];
          }
     
     
        //mysql_select_db($database_conncz, $conncz);
        //$query_Recordset1 = sprintf("SELECT * FROM pub WHERE client = %s", GetSQLValueString($colname_Recordset1, "text"));
        //$Recordset1 = mysql_query($query_Recordset1, $conncz) or die(mysql_error());
        //$row_Recordset1 = mysql_fetch_assoc($Recordset1);
        //$totalRows_Recordset1 = mysql_num_rows($Recordset1);
    function afficherPhoto($nomFoto)
    {
      $result = true;
      $debut = substr($nomFoto,0,2);
      if($debut == "")
      {
        $result = false;  
      } 
      return $result;
    }
     
    function redimimage($urlimg,$maxX,$maxY)
    {
       if (file_exists($urlimg)) {
        $size = getimagesize($urlimg);
        list($width, $height) = $size;
        $ratiox=$width/$maxX;
        $ratioy=$height/$maxY;
        if($ratiox>$ratioy){$ratio=$ratiox;}else{$ratio=
    $ratioy;}
        if($ratio<1){$ratio=1;}
        echo "<img border=0 src=".$urlimg." width=".(int)($width/$ratio)." height=".(int)($height/$ratio).">";
       }
    }
     
     
    ?>
    <!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"><!-- InstanceBegin template="/Templates/comm.dwt.php" codeOutsideHTMLIsLocked="false" -->
    <head>
     
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Modifier les textes de votre page </title>
    <!-- InstanceEndEditable --> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <!-- InstanceBeginEditable name="head" -->
    <style type="text/css">
    <!--
    .fenetrecomm {
    	font-family: Arial, Helvetica, sans-serif;
    	font-size: 12px;
    	color: #000000;
    	scrollbar-face-color:#FBBC00;
    	scrollbar-highlight-color:#FFFFFF;
    	scrollbar-shadow-color:#000000;
    	scrollbar-arrow-color:#000033;
    	scrollbar-track-color:#FFCC66;
    	padding: 5px;
    	border: 1px solid #6699CC;
    	margin: 5px;
    	background-color: #E6F0F9;
    }
    .apu {
    	font-family: Arial, Helvetica, sans-serif;
    	font-size: 10px;
    	color: #000000;
    	padding: 0px 4px;
    	margin: 0px;
    	background-color: #FFDF5E;
    }
    -->
    </style>
    <script type="text/javascript">
    <!--
    function effacer()
    {
     document.getElementById("idTextarea").value="";
    }
     
    function effacer2()
    {
     document.getElementById("idTextarea2").value="";
    }
     
    function effacer3()
    {
     document.getElementById("idTextarea3").value="";
    }
     
    function effacer4()
    {
     document.getElementById("idTextarea4").value="";
    }
     
    function effacer5()
    {
     document.getElementById("idTextarea5").value="";
    }
     
    function bannir(ch)
    {
    ch=ch.replace(/href/g,'***');
    ch=ch.replace(/http/g,'***');
    return ch;
    }
     
    function limite(zone,max)
    {
    if(zone.value.length>=max){zone.value=zone.value.substring(0,max);}
    }
     
     
    //-->
    </script>
    .................

    et le form est comme ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    <form style="margin:0px; padding:0px;" staction="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2">
                              <table style="border:solid 1px grey;" width="95%" border="0" align="center" cellpadding="5" cellspacing="0" >
                                <tr valign="baseline">
                                  <td style="border-bottom:solid 1px grey;" colspan="2" align="center" valign="middle"><?php
    if(afficherPhoto($row_Recordset1['img1']) == true) {
       echo redimimage("../../../images/pub/img-clients/".$row_Recordset1['img1'],500,150);
    } ?>
     
                                    <br />         
     
                                   <input onkeyup="limite(this,80);" onkeydown="limite(this,80);" onBlur="this.value=bannir(this.value)" class="fenetrecomm" style="text-align:center; font-style:italic;" type="text" name="slogan" value="<?php echo htmlentities($row_Recordset1['slogan'], ENT_COMPAT, 'iso-8859-1'); ?>" size="80" /></td>
                                </tr>
                                <tr valign="baseline">
                                  <td colspan="2" align="center" valign="top" style="border-bottom: solid grey 1px;"><textarea name="texte1" onBlur="this.value=bannir(this.value)" id="idTextarea" cols="80" rows="7" class="fenetrecomm"><?php echo htmlentities($row_Recordset1['texte1'], ENT_COMPAT, 'iso-8859-1'); ?></textarea>
                                  <input title="Êtes-vous sûr ?" class="apu" type="button" value="Effacer"  onclick="effacer()" /></td>
                                </tr>
                                <tr>
                                  <td  style="border-bottom:solid 1px grey;"colspan="2"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                                  	<tr>
                                    	<td width="310" align="center" valign="middle" style="background-image:url(../../../images/pub/images/img2.jpg); background-position:center; background-repeat:no-repeat;"   >
                                  <?php
    if(afficherPhoto($row_Recordset1['img2']) == true) {
       echo redimimage("../../../images/pub/img-clients/".$row_Recordset1['img2'],300,300);
    } ?>                                
                                    </td>
                                    <td align="center"><textarea onBlur="this.value=bannir(this.value)" id="idTextarea2" style="font-size:11px;" name="texte2" cols="27" rows="7" class="fenetrecomm"><?php echo htmlentities($row_Recordset1['texte2'], ENT_COMPAT, 'iso-8859-1'); ?></textarea><input type="button" class="apu" onclick="effacer2()" value="Effacer" title="Êtes-vous sûr ?"  /></td>
                                    </tr>
                                  </table></td>
                                </tr>
                                <tr valign="baseline">
                                  <td style="border-bottom:solid 1px grey;"  colspan="2" align="right" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="center">
                                    <textarea onBlur="this.value=bannir(this.value)" id="idTextarea3" style="font-size:11px" name="texte3" cols="30" rows="7" class="fenetrecomm"><?php echo htmlentities($row_Recordset1['texte3'], ENT_COMPAT, 'iso-8859-1'); ?></textarea><input type="button" class="apu" onclick="effacer3()" value="Effacer" title="Êtes-vous sûr ?"  />
                                 </td>
                                  <td width="310" align="center" valign="middle" style="background-image:url(../../../images/pub/images/img3.jpg); background-position:center; background-repeat:no-repeat;"> <?php
    if(afficherPhoto($row_Recordset1['img3']) == true) {
       echo redimimage("../../../images/pub/img-clients/".$row_Recordset1['img3'],300,300);
    } ?> </td>
                                </tr></table></td></tr>
                                <tr valign="baseline">
                                  <td style="border-bottom:solid 1px grey;" colspan="2" align="center" valign="top">
                                  <textarea onBlur="this.value=bannir(this.value)" name="texte4" id="idTextarea4" cols="80" rows="5" class="fenetrecomm"><?php echo htmlentities($row_Recordset1['texte4'], ENT_COMPAT, 'iso-8859-1'); ?></textarea><input type="button" class="apu" onclick="effacer4()" value="Effacer" title="Êtes-vous sûr ?"  />
    </td>
                                </tr>
                                <tr valign="baseline">
                                  <td  width="50%" height="20" align="center" valign="middle" style="border-bottom:solid 1px grey; background-image:url(../../../images/pub/images/img4.jpg); background-position:center; background-repeat:no-repeat;"> <?php
    if(afficherPhoto($row_Recordset1['img4']) == true) {
       echo redimimage("../../../images/pub/img-clients/".$row_Recordset1['img4'],260,260);
    } ?></td>
                                  <td style="border-bottom:solid 1px grey; background-image:url(../../../images/pub/images/img5.jpg); background-position:center; background-repeat:no-repeat;"  align="center" valign="middle"><?php
    if(afficherPhoto($row_Recordset1['img5']) == true) {
       echo redimimage("../../../images/pub/img-clients/".$row_Recordset1['img5'],260,260);
    } ?></td>
                                </tr>
                                <tr valign="baseline">
                                  <td style="border-bottom:solid 1px grey;"  colspan="2" align="center" valign="top">                                <textarea onBlur="this.value=bannir(this.value)" id="idTextarea5" name="texte5" cols="80" rows="5" class="fenetrecomm"><?php echo htmlentities($row_Recordset1['texte5'], ENT_COMPAT, 'iso-8859-1'); ?></textarea><input type="button" class="apu" onclick="effacer5()" value="Effacer" title="Êtes-vous sûr ?"  /></td>
                                </tr>
                                <tr valign="baseline">
                                  <td height="20" colspan="2" align="center" valign="top" style="border-bottom:solid 1px grey; background-image:url(../../../images/pub/images/img6.jpg); background-position:center; background-repeat:no-repeat;"> <?php
    if(afficherPhoto($row_Recordset1['img6']) == true) {
       echo redimimage("../../../images/pub/img-clients/".$row_Recordset1['img6'],450,450);
    } ?>
     
                                </td>
                              </tr>
     
                              </table>
     
     
     
                           <blockquote>
     
                                <p align="justify" class="arial11"><strong>&nbsp;&nbsp;&nbsp;Attention !</strong> V&eacute;rifiez bien vos textes car les modifications que vous venez de faire seront visibles instantan&eacute;ment sur votre page  d&egrave;s que vous aurez cliqu&eacute; sur le bouton <em>Enregistrer les modifications</em>.</p>
                              </blockquote>
                              <p align="center">&nbsp;</p>
                              <p align="center">
                                <input type="submit" class="bouton" value="Enregistrer les modifications" />
                              </p>
                             <p align="center">
                             <input type="hidden" name="ID_pub" value="<?php echo $row_Recordset1['ID_pub']; ?>" />
                              <input type="hidden" name="jour" value="<?php echo date('Y-m-d H:i:s') ; ?>" />
                              <input type="hidden" name="MM_update" value="form2" />
                              <input class="fenetrecomm" type="hidden" name="titrepage" value="<?php echo htmlentities($row_Recordset1['titrepage'], ENT_COMPAT, 'iso-8859-1'); ?>" size="2" />
                              <input name="test" type="hidden" value="test"/>
                              </p>
                            </form>

Discussions similaires

  1. Réponses: 4
    Dernier message: 23/04/2013, 10h21
  2. comment eviter l'affichage des lignes vides?
    Par perloutta dans le forum ASP.NET
    Réponses: 4
    Dernier message: 21/03/2009, 16h28
  3. Réponses: 2
    Dernier message: 20/07/2006, 19h40

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo