Page 1 sur 1

affichage d'infos depuis sql

Posté : 01 nov. 2005, 17:18
par yuuzhantar
bonjour

pour lister les bannières de mes visteurs, j'ai créé ce code, qui affiche des infos dans un tableau

le code est très long
<?php
$db = mysql_connect('sql.free.fr', 'xxx', 'xxx'); // 1
mysql_select_db('yuu_sw',$db); // 2
$req = mysql_query("SELECT ban_id, ban_lien, ban_emp, ban_fond, ban_color, ban_color2, ban_txt, ban_credits, ban_affiche, ban_affichage FROM a_ban WHERE user_id='$id3'"); // 3
while($data = mysql_fetch_assoc($req))
{

'<p><table width="494" height="280" border="0" cellpadding="0" cellspacing="0">';
'<tr>';
'<td colspan="2" rowspan="3"><img src="'.$data['ban_emp'].'" width="468" height="60"></td>';
'<td width="26" height="20"><div align="center"><a href="/echange/mebres/ban_infos_modif.php?ban_id='.$data['ban_id'].'" class="menulink"><strong>M</strong></a></div></td>';
'</tr>';
'<tr>';
'<td width="26" height="20"><div align="center"><a href="/echange/membres/ban_infos_delete.php?ban_id='.$data['ban_id'].'" class="menulink"><strong>S</strong></a></div></td>';
'</tr>';
'<tr>';
'<td width="26" height="20">&nbsp;</td>';
'</tr>';
'<tr>';
'<td width="71" height="20">ID</td>';
'<td width="397" height="20">'.$data['ban_id'].'</td>';
'<td width="26" height="20">&nbsp;</td>';
'</tr>';
'<tr>';
'<td width="71" height="20">Lien</td>';
'<td width="397" height="20">'.$data['ban_lien'].'</td>';
'<td width="26" height="20">&nbsp;</td>';
'</tr>';
'<tr>';
'<td width="71" height="20">Emplacement</td>';
'<td width="397" height="20">'.$data['ban_emp'].'</td>';
'<td width="26" height="20">&nbsp;</td>';
'</tr>';
'<tr>';
'<td height="20">Fond</td>';
'<td height="20">'.$data['ban_fond'].'</td>';
'<td height="20">&nbsp;</td>';
'</tr>';
'<tr>';
'<td height="20">Color1</td>';
'<td height="20">'.$data['ban_color'].'</td>';
'<td height="20">&nbsp;</td>';
'</tr>';
'<tr>';
'<td height="20">Color2</td>';
'<td height="20">'.$data['ban_color2'].'</td>';
'<td height="20">&nbsp;</td>';
'</tr>';
'<tr>';
'<td height="20">Texte</td>';
'<td height="20">'.$data['ban_txt'].'</td>';
'<td height="20">&nbsp;</td>';
'</tr>';
'<tr>';
'<td height="20">Cr&eacute;dits</td>';
'<td height="20">'.$data['ban_credits'].'</td>';
'<td height="20">&nbsp;</td>';
'</tr>';
'<tr>';
'<td height="20">affich&eacute;e</td>';
'<td height="20">votre bannière a étée affichée '.$data['ban_affiche'].' fois</td>';
'<td height="20">&nbsp;</td>';
'</tr>';
'<tr>';
'<td height="20">Affichages</td>';
'<td height="20">vous avez effectué '.$data['ban_affichage'].' avec ce compte bannière</td>';
'<td height="20">&nbsp;</td>';
'</tr>';
'<tr>';
'<td height="20">Code</td>';
'<td height="20"><p><iframe src="http://www.banniere-echange.fr.tc/frame ... id='.$data['ban_id'].'" name="frame_ban_1" width="500" height="100" scrolling="no" frameborder="0" hspace="0" vspace="0" id="frame_ban_1" border="0" ></iframe></p>';
'<p>&nbsp;</p></td>';
'<td height="20">&nbsp;</td>';
'</tr>';
'</table></p>';
}

mysql_close($db); // 6
?>
sauf que sa n'affiche rien du tout, pourtant j'ai des bannières mais ???

je vois pas ce qui ne vas pas

Posté : 01 nov. 2005, 17:27
par ouckileou
Si tu réglais d'abord ce sujet là avant : http://www.phpfrance.com/forums/voir_su ... 0-asc-.php

Et pour coller du code PHP tu as des balises
 plutôt que faire une citation

Posté : 01 nov. 2005, 17:31
par yuuzhantar
a, j'avais pas vu les balises php

bon, l'autre sujet est réglé, il ne reste plus que celui la

Posté : 01 nov. 2005, 17:35
par yuuzhantar
déjà, apparement, sa ne vient pas du tableau car pour voir j'ai un peut modifié le code pour mettre sa
<?php 
$db = mysql_connect('sql.free.fr', 'yuu.sw', '794212');  // 1 
mysql_select_db('yuu_sw',$db);                    // 2 
$req = mysql_query("SELECT ban_id, ban_lien, ban_emp, ban_fond, ban_color, ban_color2, ban_txt, ban_credits, ban_affiche, ban_affichage FROM a_ban WHERE user_id='$id3'");          // 3 
while($data = mysql_fetch_assoc($req))
	{
	'echo "votre lien de bannière est '.$data['ban_lien'].'"';
	}

mysql_close($db);  // 6 
?>

sa doit venir de la requete car la aussi sa n'affiche rien

Posté : 01 nov. 2005, 17:39
par Truc
Pour voir si c'est la requete qui ne va pas teste la :wink:
deja décompose:
$sql="SELECT ban_id, ban_lien, ban_emp, ban_fond, ban_color, ban_color2, ban_txt, ban_credits, ban_affiche, ban_affichage FROM a_ban WHERE user_id=".$id3;
echo $sql; // fait un copier coller dans phpmyadmin et regarde si tu as un résultat
$req = mysql_query($sql);

Posté : 01 nov. 2005, 17:49
par yuuzhantar
pour l'instant sa sa marche

sa affiche sur la page
SELECT ban_id, ban_lien, ban_emp, ban_fond, ban_color, ban_color2, ban_txt, ban_credits, ban_affiche, ban_affichage FROM a_ban WHERE user_id='1'

donc c'est bon

sa viens alors de la suite avec le while

Posté : 01 nov. 2005, 18:01
par yuuzhantar
$sql="SELECT ban_id, ban_lien, ban_emp, ban_fond, ban_color, ban_color2, ban_txt, ban_credits, ban_affiche, ban_affichage FROM a_ban WHERE user_id='$id3'"; 
echo $sql; // fait un copier coller dans phpmyadmin et regarde si tu as un résultat 
$req = mysql_query($sql); 
while($data = mysql_fetch_assoc($req))
	{
	'echo "votre lien de bannière est '.$data['ban_lien'].'"';
	}
c dans cette partie qu'il y a un bug

Posté : 01 nov. 2005, 18:02
par Truc
ne met pas le echo entre apostrophes !!
echo "votre lien de bannière est ".$data['ban_lien']; 

Posté : 01 nov. 2005, 18:06
par yuuzhantar
exact

je viens de tester
c bon

Posté : 01 nov. 2005, 18:14
par yuuzhantar
en fait c pas bon

maintenant, mon code est celui-ci
<?php 
$db = mysql_connect('sql.free.fr', 'xxx', 'xxx');  // 1 
mysql_select_db('yuu_sw',$db);                    // 2 
$req = mysql_query("SELECT ban_id, ban_lien, ban_emp, ban_fond, ban_color, ban_color2, ban_txt, ban_credits, ban_affiche, ban_affichage FROM a_ban WHERE user_id='$id3'");          // 3 
while($data = mysql_fetch_assoc($req))
	{
	<p>;
	<table width="494" height="280" border="0" cellpadding="0" cellspacing="0">;
        <tr>;
          <td colspan="2" rowspan="3"><img src="'.$data['ban_emp'].'" width="468" height="60"></td>;
          <td width="26" height="20"><div align="center"><a href="/echange/mebres/ban_infos_modif.php?ban_id='.$data['ban_id'].'" class="menulink"><strong>M</strong></a></div></td>;
        </tr>;
        <tr>;
          <td width="26" height="20"><div align="center"><a href="/echange/membres/ban_infos_delete.php?ban_id='.$data['ban_id'].'" class="menulink"><strong>S</strong></a></div></td>;
        </tr>;
        <tr>;
          <td width="26" height="20">&nbsp;</td>;
        </tr>;
        <tr>;
          <td width="71" height="20">ID</td>;
          <td width="397" height="20">'.$data['ban_id'].'</td>;
          <td width="26" height="20">&nbsp;</td>;
        </tr>;
        <tr>;
          <td width="71" height="20">Lien</td>;
          <td width="397" height="20">'.$data['ban_lien'].'</td>;
          <td width="26" height="20">&nbsp;</td>;
        </tr>;
        <tr>;
          <td width="71" height="20">Emplacement</td>;
          <td width="397" height="20">'.$data['ban_emp'].'</td>;
          <td width="26" height="20">&nbsp;</td>;
        </tr>;
        <tr>;
          <td height="20">Fond</td>;
          <td height="20">'.$data['ban_fond'].'</td>;
          <td height="20">&nbsp;</td>;
        </tr>;
        <tr>;
          <td height="20">Color1</td>;
          <td height="20">'.$data['ban_color'].'</td>;
          <td height="20">&nbsp;</td>;
        </tr>;
        <tr>;
          <td height="20">Color2</td>;
          <td height="20">'.$data['ban_color2'].'</td>;
          <td height="20">&nbsp;</td>;
        </tr>;
        <tr>;
          <td height="20">Texte</td>;
          <td height="20">'.$data['ban_txt'].'</td>;
          <td height="20">&nbsp;</td>;
        </tr>;
        <tr>;
          <td height="20">Cr&eacute;dits</td>;
          <td height="20">'.$data['ban_credits'].'</td>;
          <td height="20">&nbsp;</td>;
        </tr>;
        <tr>;
          <td height="20">affich&eacute;e</td>;
          <td height="20">votre bannière a étée affichée '.$data['ban_affiche'].' fois</td>;
          <td height="20">&nbsp;</td>;
        </tr>;
        <tr>;
          <td height="20">Affichages</td>;
          <td height="20">vous avez effectué '.$data['ban_affichage'].' avec ce compte bannière</td>;
          <td height="20">&nbsp;</td>;
        </tr>;
        <tr>;
          <td height="20">Code</td>;
          <td height="20"><iframe src="http://www.banniere-echange.fr.tc/frames/frame_ban_1.php?ban_id='.$data['ban_id'].'" name="frame_ban_1" width="500" height="100" scrolling="no" frameborder="0" hspace="0" vspace="0" id="frame_ban_1" border="0" ></iframe>;
          <p>&nbsp;</p></td>;
          <td height="20">&nbsp;</td>;
        </tr>;
      </table>;
	  </p>; 
	}

mysql_close($db);  // 6 
?>
et sa me met
Parse error: parse error, unexpected '<' in /var/www/sdc/0/8/yuu.sw/echange/membres/ban_infos.php on line 115
la ligne 115 est celle ci
	<p>;
ca c'est embettant

Posté : 01 nov. 2005, 18:26
par yuuzhantar
sa y est

à chaque ligne, j'ai mis un echo ' ';

sa affiche quelque chose maintenant

il n'y a plus qu'un petit bug

Posté : 01 nov. 2005, 18:34
par ouckileou
ben ça
<p>;
c'est du HTML
qu'est-ce que ça vient faire au milieu du PHP ?

si tu veux écrire du code HTML utilise des fonctions pour écrire : echo, print...etc