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 :

Case à cocher


Sujet :

PHP & Base de données

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau membre du Club
    Inscrit en
    Mai 2008
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Mai 2008
    Messages : 6
    Par défaut Case à cocher
    Salut, je reviens vers vous avec une autre question :
    J'ai fait une page avec un formulaire avec lequel j'insère des données dans ma base de données. Et il y a aussi une autre page "MODIFICATION" ou la je voudrais modifier toutes les données inscrites déjà. Seul petit souci, je n'arrive pas a faire afficher les case a cocher qui ont été selectionnes dans la page "INSERTION".
    Aidez moi svp.
    je vous mets mon code ci dessous :
    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
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    <?php require_once('Connections/immobilis.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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"] == "form_modif_maison")) {
      $updateSQL = sprintf("UPDATE vente_maison SET nom=%s, prenom=%s, telephone=%s, portable=%s, adresse1=%s, adresse2=%s, adresse3=%s, email=%s, type=%s, region=%s, ville=%s, surface=%s, superficie=%s, pieces=%s, chambre=%s, bains=%s, prix=%s, descriptif=%s, jardin=%s, terasse=%s, balcon=%s, cour_cloture=%s, cave=%s, grenier=%s, garage=%s, climatise=%s, parquet=%s, carrelage=%s, piscine=%s, systeme_alarme=%s, chauffe_eau_solaire=%s, chauffe_eau_electrique=%s, porte_automatise=%s, photo1=%s, photo2=%s, photo3=%s, photo4=%s, photo5=%s WHERE `ref`=%s",
                           GetSQLValueString($_POST['nom'], "text"),
                           GetSQLValueString($_POST['prenom'], "text"),
                           GetSQLValueString($_POST['telephone'], "int"),
                           GetSQLValueString($_POST['portable'], "int"),
                           GetSQLValueString($_POST['adresse1'], "text"),
                           GetSQLValueString($_POST['adresse2'], "text"),
                           GetSQLValueString($_POST['adresse3'], "text"),
                           GetSQLValueString($_POST['email'], "text"),
                           GetSQLValueString($_POST['type'], "text"),
                           GetSQLValueString($_POST['region'], "text"),
                           GetSQLValueString($_POST['ville'], "text"),
                           GetSQLValueString($_POST['surface'], "int"),
                           GetSQLValueString($_POST['superficie'], "int"),
                           GetSQLValueString($_POST['pieces'], "int"),
                           GetSQLValueString($_POST['chambre'], "int"),
                           GetSQLValueString($_POST['bains'], "int"),
                           GetSQLValueString($_POST['prix'], "int"),
                           GetSQLValueString($_POST['descriptif'], "text"),
                           GetSQLValueString(isset($_POST['jardin']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['terasse']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['balcon']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['cour_cloture']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['cave']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['grenier']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['garage']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['climatise']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['parquet']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['carrelage']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['piscine']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['systeme_alarme']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['chauffe_eau_solaire']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['chauffe_eau_electrique']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString(isset($_POST['porte_automatise']) ? "true" : "", "defined","1","0"),
                           GetSQLValueString($_POST['photo1'], "text"),
                           GetSQLValueString($_POST['photo2'], "text"),
                           GetSQLValueString($_POST['photo3'], "text"),
                           GetSQLValueString($_POST['photo4'], "text"),
                           GetSQLValueString($_POST['photo5'], "text"),
                           GetSQLValueString($_POST['ref'], "text"));
     
      mysql_select_db($database_immobilis, $immobilis);
      $Result1 = mysql_query($updateSQL, $immobilis) or die(mysql_error());
    }
    ?>
    <?php require_once('Connections/immobilis.php'); ?>
    <?php
    mysql_select_db($database_immobilis, $immobilis);
    $query_choice = "SELECT `ref` FROM vente_maison";
    $choice = mysql_query($query_choice, $immobilis) or die(mysql_error());
    $row_choice = mysql_fetch_assoc($choice);
    $totalRows_choice = mysql_num_rows($choice);
     
    $colname_modif = "-1";
    if (isset($_POST['ref_mod'])) {
      $colname_modif = (get_magic_quotes_gpc()) ? $_POST['ref_mod'] : addslashes($_POST['ref_mod']);
    }
    mysql_select_db($database_immobilis, $immobilis);
    $query_modif = sprintf("SELECT * FROM vente_maison WHERE `ref` = '%s'", $colname_modif);
    $modif = mysql_query($query_modif, $immobilis) or die(mysql_error());
    $row_modif = mysql_fetch_assoc($modif);
    $totalRows_modif = mysql_num_rows($modif);
    ?>
    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Immobilis-vente</title>
    <link href="css/navigation.css" rel="stylesheet" type="text/css" />
    <link href="css/nav_type_de_bien.css" rel="stylesheet" type="text/css" />
    <link href="css/vente_insertion.css" rel="stylesheet" type="text/css" />
    </head>
     
    <body>
    <div id="main">
    	<div id="header"></div>
    <div id="navigation"> 
      <?php include('include/nav_vente_modification.inc.php'); ?>
     
    	<div id="vente_gauche">
      		<div id="texte_gauche_vente"></div>
    </div>
    <div id="milieu">
     
        <div id="reference">
          <form id="choice" name="choice" method="post" action="modification_vente_maison.php">
    S&eacute;lectionner la r&eacute;f&eacute;rence &agrave; modifier :
    <select name="ref_mod" id="ref_mod">
      <option value=""></option>
    <?php
    do {  
    ?>
      <option value="<?php echo $row_choice['ref']?>"><?php echo $row_choice['ref']?></option>
      <?php
    } while ($row_choice = mysql_fetch_assoc($choice));
      $rows = mysql_num_rows($choice);
      if($rows > 0) {
          mysql_data_seek($choice, 0);
    	  $row_choice = mysql_fetch_assoc($choice);
      }
    ?>
            </select>
          <label>
          <input name="Submit3" type="submit" class="bouton" value="OK" />
          </label>
          </form>
        </div>
    <div id="navigation_type"> 
      			<ul class="nav_type">
       				<li class="here"><a href="#">Maison</a></li>
    <li><a href="insertion_vente_appart.php">Appartement</a></li>
    <li><a href="insertion_vente_bungalow.php">Bungalow</a></li>
    <li><a href="insertion_vente_villa.php">Villa</a></li>
    <li><a href="insertion_vente_commercial.php">Espace commercial</a></li>
    <li><a href="insertion_vente_terrain.php">Terrain</a></li>
    </ul> 
      </div>
    </div>
    <form action="<?php echo $editFormAction; ?>" method="POST" name="form_modif_maison">
    <div id="details_vendeur">
    			<div id="details_vendeur_texte">
    			<table width="700" border="0" cellspacing="5" cellpadding="0">
      			<tr>
        			<td width="260">&nbsp;</td>
        			<td><strong>Nom&nbsp;</strong></td>
        			<td><input name="nom" type="text" class="textfield_20" id="nom" value="<?php echo $row_modif['nom']; ?>" size="20" /></td>
        			<td width="10">&nbsp;</td>
        			<td><strong>Pr&eacute;nom&nbsp;</strong></td>
        			<td><input name="prenom" type="text" class="textfield_20" id="prenom" value="<?php echo $row_modif['prenom']; ?>" size="20" /></td>
      			</tr>
    			</table>
     
    			<table width="700" border="0" cellspacing="10" cellpadding="0">
      			<tr>
        			<td><strong>T&eacute;l&eacute;phone</strong></td>
        			<td><input name="telephone" type="text" class="textfield_25" id="telephone" value="<?php echo $row_modif['telephone']; ?>" size="25" /></td>
        			<td width="235"><div align="right"><strong>Portable</strong></div></td>
        			<td><input name="portable" type="text" class="textfield_25" id="portable" value="<?php echo $row_modif['portable']; ?>" size="25" /></td>
      			</tr>
      			<tr>
        			<td><strong>Adresse</strong></td>
        			<td><input name="adresse1" type="text" class="textfield_25" id="adresse1" value="<?php echo $row_modif['adresse1']; ?>" size="25" /></td>
        			<td><div align="center"><input name="adresse2" type="text" class="textfield_25" id="adresse2" value="<?php echo $row_modif['adresse2']; ?>" size="25" />
        			</div>	</td>
        			<td><input name="adresse3" type="text" class="textfield_25" id="adresse3" value="<?php echo $row_modif['adresse3']; ?>" size="25" /></td>
      			</tr>
      			<tr>
        			<td><strong>Email</strong></td>
        			<td colspan="2"><input name="email" type="text" class="textfield_50" id="email" value="<?php echo $row_modif['email']; ?>" size="50" /></td>
        			<td>&nbsp;</td>
      			</tr>
    			</table>
      </div>
    </div>
    <div id="details_insertion_bien">
    		<div id="type_">
     			<table width="355" border="0" cellspacing="5" cellpadding="0">
      			<tr>
        			<td width="105">Ref <input name="ref" type="text" class="textfield_10" id="ref" value="<?php echo $row_modif['ref']; ?>" /></td>
    				<td>Type de bien <input name="type" type="text" class="textfield_20" id="type" value="MAISON" /></td>
      			</tr>
      			</table>
    			<table width="368" border="0" cellspacing="4" cellpadding="0">
    		  	<tr>
        			<td width="173">Region 
          				<select name="region" id="region" title="<?php echo $row_modif['region']; ?>">
    			        <option>Nord</option>
    			        <option>Sud</option>
    			        <option>Est</option>
    			        <option>Ouest</option>
    			        <option>Centre</option>
    	      	  </select>
    			  </td>
        			<td width="2">&nbsp;</td>
        			<td>Ville <input name="ville" type="text" class="textfield_15" id="ville" value="<?php echo $row_modif['ville']; ?>" /></td>
      			</tr>
    			<tr>
        			<td>Surface habitable<input name="surface" type="text" class="textfield_05" id="surface" value="<?php echo $row_modif['surface']; ?>" />
        			m2 </td>
        			<td width="1">&nbsp;</td>
        			<td>Superficie terrain&nbsp;
        			  <input name="superficie" type="text" class="textfield_05" id="superficie" value="<?php echo $row_modif['superficie']; ?>" />
        			  m2</td>
      			</tr>
    		  </table>
    			<table width="355" border="0" cellspacing="4" cellpadding="0">
    			<tr>
    			    <td width="120">Nombre de pi&egrave;ces </td>
    			    <td><input name="pieces" type="text" class="textfield_05" id="pieces" value="<?php echo $row_modif['pieces']; ?>" /></td>
    			    <td width="10">&nbsp;</td>
    			    <td>Chambre &agrave; coucher </td>
    			    <td><input name="chambre" type="text" class="textfield_05" id="chambre" value="<?php echo $row_modif['chambre']; ?>" /></td>
    		  	</tr>
    	  		<tr>
    			    <td>Salle de bains </td>
    			    <td><input name="bains" type="text" class="textfield_05" id="bains" value="<?php echo $row_modif['bains']; ?>" /></td>
    			    <td width="10">&nbsp;</td>
    			    <td colspan="2"><strong>Prix</strong>&nbsp;&nbsp;Rs&nbsp;&nbsp;
    		      	<input name="prix" type="text" class="textfield_15" id="prix" value="<?php echo $row_modif['prix']; ?>" /> </td>
      			</tr>
    			</table>
     
    			<table width="120" border="0" cellspacing="0" cellpadding="0">
      			<tr>
        			<td width="355" valign="top">
    				Descriptif du bien      
    				<textarea name="descriptif" class="zone_texte" id="descriptif"><?php echo $row_modif['descriptif']; ?></textarea>				</td>
        		</tr>
    			</table>
    	</div>
    <div id="options">
    		<table width="315" border="0" cellpadding="0" cellspacing="1" class="texte_opt">
      		<tr>
        		<td>Jardin</td>
        		<td width="10"><input name="jardin" type="checkbox" id="jardin" value="jardin" <?php if (!(strcmp($row_modif['jardin'],"jardin"))) {echo "checked=\"checked\"";} ?> /></td>
        		<td width="15">&nbsp;</td>
        		<td>Cour clotur&eacute;e </td>
        		<td width="10"><input <?php if (!(strcmp($row_modif['cour_cloture'],"cour_clotuture"))) {echo "checked=\"checked\"";} ?> name="cour_cloture" type="checkbox" id="cour_cloture" /></td>
        	</tr>
      		<tr>
        		<td>Balcon</td>
        		<td width="10"><input name="balcon" type="checkbox" id="balcon" /></td>
        		<td width="15">&nbsp;</td>
        		<td>Terasse </td>
        		<td width="10"><input name="terasse" type="checkbox" id="terasse" /></td>
        	</tr>
      		<tr>
        		<td>Cave</td>
        		<td width="10"><input name="cave" type="checkbox" id="cave" /></td>
        		<td width="15">&nbsp;</td>
        		<td>Grenier</td>
        		<td width="10"><input name="grenier" type="checkbox" id="grenier" /></td>
        	</tr>
     
      		<tr>
        		<td>Parquet</td>
        		<td width="10"><input name="parquet" type="checkbox" id="parquet" /></td>
        		<td width="15">&nbsp;</td>
        		<td>Carrelage</td>
        		<td width="10"><input name="carrelage" type="checkbox" id="carrelage" /></td>
        	</tr>
      		<tr>
        		<td>Chauffe-eau solaire </td>
        		<td width="10"><input name="chauffe_eau_solaire" type="checkbox" id="chauffe_eau_solaire" /></td>
        		<td width="15">&nbsp;</td>
        		<td>Chauffe-eau &eacute;lectrique </td>
        		<td width="10"><input name="chauffe_eau_electrique" type="checkbox" id="chauffe_eau_electrique" /></td>
        	</tr>  		
      		<tr>
        		<td>Porte automatis&eacute;e</td>
        		<td><input name="porte_automatise" type="checkbox" id="porte_automatise" /></td>
        		<td>&nbsp;</td>
        		<td>Garage</td>
        		<td><input name="garage" type="checkbox" id="garage" /></td>
      		</tr>
      		<tr>
        		<td>Syst&egrave;me d'alarme </td>
        		<td><input name="systeme_alarme" type="checkbox" id="systeme_alarme" /></td>
        		<td>&nbsp;</td>
        		<td>Climatis&eacute;</td>
        		<td><input name="climatise" type="checkbox" id="climatise" /></td>
      		</tr>
    		<tr>
        		<td>Piscine</td>
        		<td width="10"><input name="piscine" type="checkbox" id="piscine" /></td>
        		<td width="15">&nbsp;</td>
        		<td>&nbsp;</td>
        		<td width="10">&nbsp;</td>
    		</tr>
    		</table>
      </div>
    </div>
    <div id="details_insertion_photo">
    	<table width="750" border="0" cellspacing="10">
      	<tr>
    		<td width="270" height="26">&nbsp;</td>
        	<td width="125" height="30" class="photo_texte_prin">Photo principale</td>
        	<td><input name="photo1" type="text" class="textfield_50" id="photo1" value="<?php echo $row_modif['photo1']; ?>" />
      	</tr>
    	</table>
    	<table width="750" border="0" cellspacing="5" cellpadding="0">
      	<tr>
      	  <td width"10">&nbsp;</td>
        	<td class="photo_texte_sec" width="50">Photo 2</td>
        	<td width="275"><input name="photo2" type="text" class="textfield_45" id="photo2" value="<?php echo $row_modif['photo2']; ?>" /></td>
        	<td class="photo_texte_sec" width="50">Photo 3</td>
        	<td width="275"><input name="photo3" type="text" class="textfield_45" id="photo3" value="<?php echo $row_modif['photo3']; ?>" /></td>
      	</tr>
      	<tr>
      	  <td width="10" class="photo_texte_sec">&nbsp;</td>
        	<td class="photo_texte_sec">Photo 4</td>
        	<td><input name="photo4" type="text" class="textfield_45" id="photo4" value="<?php echo $row_modif['photo4']; ?>" /></td>
        	<td class="photo_texte_sec">Photo 5</td>
        	<td><input name="photo5" type="text" class="textfield_45" id="photo5" value="<?php echo $row_modif['photo5']; ?>" /></td>
      	</tr>
    	</table>
    	<table width="750" border="0" cellspacing="0" cellpadding="0">
      		<tr>
        		<td><div align="center">
                  <input name="Submit" type="submit" class="bouton" value="Modifiez" />
    </div></td>
        		<td><div align="center">
          		<input name="Submit2" type="submit" class="bouton" value="Réinitialiser" />
        		</div></td>
      		</tr>
    	</table>
      </div>
    <div id="footer_insertion">
    	Copyright Immobilis 2008 &copy; - <a href="mailto:natgraphics2004@yahoo.fr?subject= Feedback Immobilis">Contact Webmaster</a>
      </div>
    <input type="hidden" name="MM_update" value="form_modif_maison">
    </form>
     
    </div>
     
     
     
     
    <?php
    mysql_free_result($choice);
     
    mysql_free_result($modif);
    ?>

  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
    il faut faire quelque chose comme ca :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    ($valeurdanslabase == 1) ? $checked = ' checked="checked" ' : $checked="";
    echo '<input name="piscine" type="checkbox" ' . $checked . ' id="piscine" />';
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

Discussions similaires

  1. [MIGRATION] champ de type "case à cocher"
    Par The_Nail dans le forum MS SQL Server
    Réponses: 9
    Dernier message: 10/05/2011, 11h07
  2. Case à cocher dans une requête
    Par kloss dans le forum Access
    Réponses: 6
    Dernier message: 14/10/2004, 11h44
  3. Récupérer toutes les cases à cocher
    Par psyco2604 dans le forum ASP
    Réponses: 7
    Dernier message: 14/10/2004, 10h54
  4. Activer cases à cocher
    Par schnito dans le forum MFC
    Réponses: 4
    Dernier message: 24/01/2004, 16h07
  5. [CR] Création de tableau et case à cocher
    Par aysse dans le forum SAP Crystal Reports
    Réponses: 3
    Dernier message: 26/11/2003, 17h07

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