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 :

Probleme avec un while issu de Dream 8 [MySQL]


Sujet :

PHP & Base de données

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    187
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 187
    Points : 74
    Points
    74
    Par défaut Probleme avec un while issu de Dream 8
    bonjour, je viens en dernier recours :

    j'ai une boucle qui m'affiche mes photos.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <?php do { ?>
    //TD qui affiche une photo
     <?php } while ($row_listerPhotos = mysql_fetch_assoc($listerPhotos)); ?>
    La, tous va bien sauf que quand j'ai 0 photos, il fais la boucle une fois et maffiche une image vide avec le nom d ela balise Alt.

    Du coup j'ai fais :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
     <?php while ($row_listerPhotos = mysql_fetch_assoc($listerPhotos)) { ?>
    //TD qui affiche une photo
    <?php } ; ?>
    La, quand j'ai deux photos il en affiche qu'une, quand j'en est 3 il en affiche 2 etc...

    je vous met le code de la page entiere:
    (prené pas peur, je liste avec dream, mais aprés quand tous marche je mes tous en XHTML Strict)

    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
     
    <?php require_once('Connections/root.php'); ?><?php require_once('Connections/root.php');
    ini_set('session.use_trans_sid', false);
    ini_set('session.use_cookies', true);
    ini_set('url_rewriter.tags',''); 
    ?>
    <?php
    //initialize the session
    if (!isset($_SESSION)) {
      session_start();
      if (!isset($_SESSION['profilActif'])){
      $_SESSION['profilActif']="1";
      }
    }
    if (isset($_GET['user'])) {
      $_SESSION['profilActif']=$_GET['user'];
    }
    // ** Logout the current user. **
    $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
    if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
      $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
    }
     
    if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
      //to fully log out a visitor we need to clear the session varialbles
      $_SESSION['MM_Username'] = NULL;
      $_SESSION['MM_UserGroup'] = NULL;
      $_SESSION['PrevUrl'] = NULL;
      $_SESSION['profilActif'] = NULL;
      unset($_SESSION['MM_Username']);
      unset($_SESSION['MM_UserGroup']);
      unset($_SESSION['PrevUrl']);
      unset($_SESSION['profilActif']);
      unset($_SESSION);
     
      $logoutGoTo = "index.php";
      if ($logoutGoTo) {
        header("Location: $logoutGoTo");
        exit;
      }
    }
    ?>
    <?php
    mysql_select_db($database_root, $root);
    $query_listerCategorie = "SELECT * FROM tabl_categorie ORDER BY cate_id ASC";
    $listerCategorie = mysql_query($query_listerCategorie, $root) or die(mysql_error());
    $row_listerCategorie = mysql_fetch_assoc($listerCategorie);
    $totalRows_listerCategorie = mysql_num_rows($listerCategorie);
     
    $colname_detailsProprietaire = "-1";
    if (isset($_SESSION['profilActif'])) {
      $colname_detailsProprietaire = (get_magic_quotes_gpc()) ? $_SESSION['profilActif'] : addslashes($_SESSION['profilActif']);
    }
    mysql_select_db($database_root, $root);
    $query_detailsProprietaire = sprintf("SELECT user_id, user_nom, user_prenom, user_mail, user_ville, user_age, user_etude FROM tabl_user WHERE user_id = %s", $colname_detailsProprietaire);
    $detailsProprietaire = mysql_query($query_detailsProprietaire, $root) or die(mysql_error());
    $row_detailsProprietaire = mysql_fetch_assoc($detailsProprietaire);
    $totalRows_detailsProprietaire = mysql_num_rows($detailsProprietaire);
     
    $colname_detailsArticle = "-1";
    if (isset($_GET['idMedia'])) {
      $colname_detailsArticle = (get_magic_quotes_gpc()) ? $_GET['idMedia'] : addslashes($_GET['idMedia']);
    }
    mysql_select_db($database_root, $root);
    $query_detailsArticle = sprintf("SELECT * FROM tabl_media WHERE medi_id = %s", $colname_detailsArticle);
    $detailsArticle = mysql_query($query_detailsArticle, $root) or die(mysql_error());
    $row_detailsArticle = mysql_fetch_assoc($detailsArticle);
    $totalRows_detailsArticle = mysql_num_rows($detailsArticle);
     
    $colname_listerPhotos = "-1";
    if (isset($_GET['idMedia'])) {
      $colname_listerPhotos = (get_magic_quotes_gpc()) ? $_GET['idMedia'] : addslashes($_GET['idMedia']);
    }
    mysql_select_db($database_root, $root);
    $query_listerPhotos = sprintf("SELECT * FROM rela_media WHERE id_media = %s AND id_type = '1' ", $colname_listerPhotos);
    $listerPhotos = mysql_query($query_listerPhotos, $root) or die(mysql_error());
    $row_listerPhotos = mysql_fetch_assoc($listerPhotos);
    $totalRows_listerPhotos = mysql_num_rows($listerPhotos);
     
    $colname_listerVideos = "-1";
    if (isset($_GET['idMedia'])) {
      $colname_listerVideos = (get_magic_quotes_gpc()) ? $_GET['idMedia'] : addslashes($_GET['idMedia']);
    }
    mysql_select_db($database_root, $root);
    $query_listerVideos = sprintf("SELECT * FROM rela_media WHERE id_media = %s AND id_type = '2' ", $colname_listerVideos);
    $listerVideos = mysql_query($query_listerVideos, $root) or die(mysql_error());
    $row_listerVideos = mysql_fetch_assoc($listerVideos);
    $totalRows_listerVideos = mysql_num_rows($listerVideos);
    ?>
    <?php
    // *** Validate request to login to this site.
     
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
      $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    }
     
    if (isset($_POST['mail'])) {
      $loginUsername=$_POST['mail'];
      $password=$_POST['password'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "index.php";
      $MM_redirectLoginFailed = "index.php?erreur=true";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_root, $root);
     
      $LoginRS__query=sprintf("SELECT user_mail, user_password FROM tabl_user WHERE user_mail='%s' AND user_password='%s'",
        get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
     
      $LoginRS = mysql_query($LoginRS__query, $root) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
     
        //declare two session variables and assign them
        $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;	      
     
        if (isset($_SESSION['PrevUrl']) && false) {
          $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
        }
        header("Location: " . $MM_redirectLoginSuccess );
      }
      else {
        header("Location: ". $MM_redirectLoginFailed );
      }
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
    <html xmlns="http://www.w3.org/1999/xhtml" lang="fr-FR" >
    	<head>
    		<title>D-spax : Webmaster / Developpeur / Graphiste</title>
    		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    		<meta name="description" content="Site personnel de Georges DEMBROSKI - Portfolio - Blog - Annonces" />
    		<meta name="keywords" content="dembroski georges, d-spax, despax, tampax, graphiste, webmaster, developpeur, portfolio, blog, annonces" /> 
    		<meta name="keyphrase" content="dembroski georges, d-spax, despax, tampax, graphiste, webmaster, developpeur, portfolio, blog, annonces" />
    		<meta name="author" content="www.d-spax.com" />
    		<meta name="reply-to" content="admin@d-spax.fr" />
    		<meta name="robots" content="index, follow" />
    		<meta name="revisit-after" content="1 day" />
    		<meta name="rating" content="general" />
    		<meta name="distribution" content="global" />
    		<link href="css/style01.css" rel="stylesheet" type="text/css" />
    		<link rel="icon" type="image/gif" href="http://www.d-spax.com/favicon.ico" />
    		<script type="text/javascript" src="/images/upload/splash.image/splash.image.js"></script>
    		<link type="text/css" rel="stylesheet" href="/images/upload/splash.image/splash.image.css" />
    	</head>	
    	<body>
    		<div id="spacework">
    			<div id="header">
    				<p>Bandeau &agrave; venir</p>
    			</div>
    			<div id="linkage">
    				<p>Arborescence &agrave; venir - <a href="index.php">Acceuil</a></p>
    			</div>
    			<div id="corp">
    				<div id="menu">
    					<p>&nbsp;</p>
    					<p>&nbsp;&nbsp;Connexion :
    					<?php
    					if (isset($_GET['erreur'])) echo " Erreur";
    					?></p>
    					<form name="formConnexion" action="<?php echo $loginFormAction; ?>" method="POST">
    					<p>&nbsp;</p>
    					&nbsp;&nbsp;<input name="mail" type="text" /><br />
    					&nbsp;&nbsp;<input name="password" type="password" />&nbsp;<input name="send" type="submit" value="Go" />
    					<p>&nbsp;</p>
    				  	</form>
    					<p>&nbsp;&nbsp;Slt <?php echo $_SESSION['MM_Username'] ; ?><p>
    					<p>&nbsp;</p>
    					<p>&nbsp;&nbsp;<a href="ajouterArticle.php">Add : Article</a><p>
    					<p>&nbsp;&nbsp;<a href="AjouterMedia.php">Add : Media</a><p>
    					<p>&nbsp;&nbsp;<a href="<?php echo $logoutAction ?>">Déconnecter</a><p>
    					<p>&nbsp;</p>
    					<p>&nbsp;</p>
    					&nbsp;&nbsp;Portfolio actif : <?php echo $_SESSION['profilActif']; ?><br />
    					&nbsp;&nbsp;<a href="portfolios.php">Lister les Portfolios</a>
    					<p>&nbsp;</p>
    					<p>&nbsp;</p>
    					<table width="200" border="0" cellpadding="0" cellspacing="0">
                          <?php do { ?>
                            <tr>
                              <td>&nbsp;&nbsp;<a href="listerArticle.php?num=<?php echo $row_listerCategorie['cate_id']; ?>"><?php echo $row_listerCategorie['cate_nom']; ?></a></td>
                            </tr>
                            <?php } while ($row_listerCategorie = mysql_fetch_assoc($listerCategorie)); ?>
                        </table>
    					<p>&nbsp;</p>
    					<p>&nbsp;</p>
    					<p>&nbsp;&nbsp;Recherche :
    					<form name="formSearch" action="resultats.php" method="POST">
    					&nbsp;&nbsp;<input name="word" type="text" />&nbsp;&nbsp;<input name="sendSearch" type="submit" value="Go" />
    					<p>&nbsp;</p>
    				  	</form>
    					<p>&nbsp;</p>						
    				</div>
    			  <div id="content">
    				  <p>&nbsp;</p>
    					<table width="796" border="0" cellpadding="0" cellspacing="0">
                          <?php do { ?>
    					  	<tr>
    						  <td width="398">nom : <?php echo $row_detailsProprietaire['user_nom']; ?></td>
                              <td width="398">prenom : <?php echo $row_detailsProprietaire['user_prenom']; ?></td>
                            </tr>
    						<tr>
    						  <td width="398">mail : <?php echo $row_detailsProprietaire['user_mail']; ?></td>
                              <td width="398">ville : <?php echo $row_detailsProprietaire['user_ville']; ?></td>
                            </tr>
                            <tr>
                              <td width="398">age : <?php echo $row_detailsProprietaire['user_age']; ?></td>
                              <td width="398">Niveau d'etude : <?php echo $row_detailsProprietaire['user_etude']; ?></td>
                            </tr>
                          <?php } while ($row_detailsProprietaire = mysql_fetch_assoc($detailsProprietaire)); ?>
                        </table>
                        <p>&nbsp;</p>
    					<p>&nbsp;</p>
        <table width="796" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                          </tr>
                          <?php do { ?>
    					    <tr>
    						  <td>Titre : <?php echo $row_detailsArticle['medi_nom']; ?></td>
                            </tr>
    					    <tr>
    						  <td>Categorie : <?php echo $row_detailsArticle['cate_id']; ?><p>&nbsp;</p></td>
                            </tr>
                            <tr>
                              <td>Descritpion :<br /><?php echo $row_detailsArticle['medi_text']; ?></td>
                            </tr>
                            <?php } while ($row_detailsArticle = mysql_fetch_assoc($detailsArticle)); ?>
                        </table>
                        <p>&nbsp;</p>
    					<p>&nbsp;</p>
    					<table width="796" border="0" cellpadding="0" cellspacing="0">
    					  <tr>
                          <?php while ($row_listerPhotos = mysql_fetch_assoc($listerPhotos)) { ?>
                              <td><a href="/images/upload/<?php echo $row_listerPhotos['rela_link']; ?>" title="&nbsp;" rel="splash.image|<?php echo $row_detailsArticle['medi_id']; ?>"><img src="images/upload/<?php echo $row_listerPhotos['rela_link']; ?>" alt="Photo" width="100" height="100" /></a></td>
                            <?php } ; ?>
    					  </tr>
                        </table>
    					<p>&nbsp;</p>
    					<p>&nbsp;</p>
    					<table border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td>id_media</td>
                            <td>id_type</td>
                            <td>rela_link</td>
                          </tr>
                          <?php do { ?>
                            <tr>
                              <td><?php echo $row_listerVideos['id_media']; ?></td>
                              <td><?php echo $row_listerVideos['id_type']; ?></td>
                              <td><?php echo $row_listerVideos['rela_link']; ?></td>
                            </tr>
                            <?php } while ($row_listerVideos = mysql_fetch_assoc($listerVideos)); ?>
                        </table>
    				    <p>&nbsp;</p>
    			  </div>				
    			</div>	
    		</div>
    		<div id="footer">
    			<div id="footer-content">
    				<?php echo "<p>www.d-spax.com © ".date(Y)." - Tous droits r&eacute;serv&eacute;s</p>"; ?>
    				<a href="http://validator.w3.org/check?uri=referer"><img src="/sites/fpdf/images/cg/xhtml.png" alt="Valid XHTML 1.0 Strict" /></a>&nbsp;&nbsp;<a href="http://jigsaw.w3.org/css-validator/validator?uri=www.midicom.fr%2Fsites%2Ffpdf%2Fcss%2Fstyle01.css"><img src="/sites/fpdf/images/cg/css.png" alt="Valid CSS" /></a>
    			</div>	
    		</div>								
    	</body>
     
    </html>
    <?php
    mysql_free_result($listerCategorie);
     
    mysql_free_result($detailsProprietaire);
     
    mysql_free_result($detailsArticle);
     
    mysql_free_result($listerPhotos);
     
    mysql_free_result($listerVideos);
    ?>

  2. #2
    Expert éminent sénior
    Avatar de mathieu
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    10 394
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 10 394
    Points : 15 755
    Points
    15 755
    Par défaut
    c'est le problème classique de Dreamweaver, supprime le premier appel à "mysql_fetch_assoc" à la ligne 46

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    187
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 187
    Points : 74
    Points
    74
    Par défaut thx
    Merci beaucoup ^^ tu m'enleve une belle epine du pied

    Merci

    Resolu ^^

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Probleme avec un While
    Par namefusion dans le forum Langage
    Réponses: 14
    Dernier message: 30/09/2012, 21h07
  2. Probleme avec un While Read
    Par julinho99 dans le forum Shell et commandes GNU
    Réponses: 6
    Dernier message: 27/01/2009, 15h02
  3. Probleme avec boucle while
    Par Slash54000 dans le forum Débuter
    Réponses: 7
    Dernier message: 22/12/2008, 09h01
  4. Réponses: 2
    Dernier message: 19/11/2006, 10h54
  5. Problème avec un while...
    Par pcdj dans le forum Linux
    Réponses: 7
    Dernier message: 17/10/2005, 22h24

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