Page 1 sur 1

Fenetre adaptative au contenu avec BDD

Posté : 07 juil. 2010, 09:32
par bromlecornu
Bonjour

Je voudrais que ma fenêtre s'adapte en taille par rapport à son contenu donc je me suis renseigné et j'ai trouvé qu'il faut à priori utiliser du javascript qui ressemble à ceci

Code : Tout sélectionner

<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Photo Ground</title> <script language="JavaScript"> <!-- function resizePopUp(monImage, monTitre) { w = window.open('','chargement','width=10,height=10'); w.document.write( "<html><head><title>"+monTitre+"</title>\n" ); w.document.write( "<script language='JavaScript'>\n"); w.document.write( "IE5=NN4=NN6=false;\n"); w.document.write( "if(document.all)IE5=true;\n"); w.document.write( "else if(document.getElementById)NN6=true;\n"); w.document.write( "else if(document.layers)NN4=true;\n"); w.document.write( "function autoSize() {\n"); w.document.write( "if(IE5) self.resizeTo(document.images[0].width+10, document.images[0].height+31)\n"); w.document.write( "else if(NN6) self.sizeToContent();\n"); w.document.write( "else window.resizeTo(document.images[0].width, document.images[0].height+20)\n"); w.document.write( "self.focus();\n"); w.document.write( "}\n</scri"); w.document.write( "pt>\n"); w.document.write( "</head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onLoad='javascript:autoSize();'>" ); w.document.write( "<a href='javascript:window.close();'><img src='"+monImage+"' border=0 alt='"+monTitre+"'></a>" ); w.document.write( "</body></html>" ); w.document.close(); } --> </script> </head> <body> <?php $sql = "SELECT * FROM albums JOIN photos ON albums.num_album = photos.num_album WHERE photos.num_photo = ".(int)$_GET['numphoto']; $result = mysql_query($sql) or die ('Erreur SQL : impossible d\'effectuer la requête : <br />'.$sql); for($i=0;$i<mysql_num_rows($result);$i++) { $row=mysql_fetch_assoc($result); echo '<img border="0" src="images/albums/' . $row['nom_album'] . '/' . $row['img_photo'] . '" />'; } ?> </body> </html>
Ensuite je sais que dans mon href qui envoi vers ma page où s'affiche mon image je dois ajouter une onClick=resizePopUp malheureusement je ne vois pas comment écrire cela au milieu de mon code php voilà à quoi mon lien ressemble.

Code : Tout sélectionner

echo '<TD background="images/menu/bg_vig.png" align="center" width="170">'; echo '<a href="image.php?numphoto=' . $albums['num_photo'] . '">'; echo '<img width="150" border="0" src="images/vignettes/'.$albums['vig_photo'].'"'; echo '"</a></TD>';
Si quelqu'un peut m'aider car je galère et il ne me reste plus que ça à faire pour finioler mon site.

Merci