Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD
PHP & SGBD Forum d'entraide sur les SGBD avec PHP. Avant de poster : FAQ BDD, toutes les FAQ PHP, cours BDD et sources BDD
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 01/03/2011, 20h52   #1
Invité de passage
 
Inscription : mars 2011
Messages : 10
Détails du profil
Informations forums :
Inscription : mars 2011
Messages : 10
Points : 1
Points : 1
Par défaut Probleme affichage template et requête

Bonjour à tous,

Je développe actuellement un site en php en lien avec une base de données (j'utilise phpmyadmin).

Pour l'aspect du site, j'ai sélectionné un template gratuit que j'ai trouvé sur le site freecsstemplates.

Je souhaitais ainsi afficher sur mon site les albums enregistré dans ma base. Le problème est que l'affichage des résultats de ma requête désorganise complètement le template (la barre de menu gauche se retrouve en bas de la page au lieu de rester à gauche).

Peut être (surement) pourrez vous m'éclairer sur la source du problème ?


Voici le script php en question, il semble correct, je pense qu'il s'agit d'un problème d'affichage mais je n'arrive pas à mettre le doigt dessus.

Code :
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
<?php
$connexion=mysql_connect("****", "******", "*****");
if (!$connexion) {
	echo "La connexion au serveur a échouée<br>";
	exit;
}
if(!mysql_select_db("*****", $connexion)) {
	echo "La connexion à la base de données à échouée<br>";
	exit;
}
 
$sql=	"select distinct titre, image, nomint, nomdis, anneesortie
		from albums, interpretes, distributeurs
		where albums.numint=interpretes.numint
		and albums.numdis=distributeurs.numdis
		order by titre asc";
 
$interrogation=mysql_query($sql,$connexion);
mysql_close($connexion);
 
if ($interrogation) {
	echo "<table cellpadding='5' cellspacing='45' border='0'>"
	."<caption align=up><B><font color=red></font></B></caption>"
	."<tr><th></th><th></th></tr>";
	while ($ligne=mysql_fetch_array($interrogation))
		echo "<tr><td>"."<img src=".$ligne['image']."><td valign=up>"
			."<b>"."<u>"."Titre :"."&nbsp;".$ligne['titre']."</b>"."</u>"."<br>"
			."Interprète :"."&nbsp".$ligne['nomint']."<br>"
			."Année de sortie :"."&nbsp".$ligne['anneesortie']."<br>"
			."Distributeur :"."&nbsp".$ligne['nomdis'];
}
 
else echo "La base de données ne renvoit aucune réponse";
?>
ab1609 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/03/2011, 21h00   #2
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 381
Points : 16 381
Pour les détails :
Tu utilises des balises obsolètes <b>, <u> etc.
Tu as du code html qui se balade et qui ne sers a rien : <B><font color=red></font></B> par exemple

Pour l'essentiel, dans ta boucle while, tu commences un <tr> et un <td> qui ne sont terminés nul part.
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/03/2011, 10h07   #3
Invité de passage
 
Inscription : mars 2011
Messages : 10
Détails du profil
Informations forums :
Inscription : mars 2011
Messages : 10
Points : 1
Points : 1
J'ai bien pris en compte tes remarques et modifié ma requête.

Cependant j'ai toujours le même problème: le simple fait d'insérer mon script php dans le template flingue la mise en page de ce dernier.

Voici le code html du template en question:

Code :
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
 
Name       : Vertebrate  
Description: A two-column, fixed-width design with dark color scheme.
Version    : 1.0
Released   : 20100423
 
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Vertebrate   by Free CSS Templates</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
	<div id="header">
		<div id="logo">
			<h1><a href="#">Vertebrate   </a></h1>
			<p> design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a></p>
		</div>
	</div>
	<!-- end #header -->
	<div id="menu">
		<ul>
			<li><a href="index.html">Accueil</a></li>
			<li class="current_page_item"><a href="http://localhost/projet_application_web/rechercher.php">Rechercher</a></li>
			<li><a href="#">Photos</a></li>
			<li><a href="#">About</a></li>
			<li><a href="#">Links</a></li>
			<li><a href="#">Contact</a></li>
		</ul>
	</div>
	<!-- end #menu -->
 
	<div id="page">
	<div id="page-bgtop">
	<div id="page-bgbtm">
		<div id="content">
			<div class="post">
				<h2 class="title"><a href="#">Welcome to Vertebrate   </a></h2>
				<p class="meta"><span class="date">September 10, 2009</span><span class="posted">Posted by <a href="#">Someone</a></span></p>
				<div style="clear: both;">&nbsp;</div>
				<div class="entry">
					<p>This is <strong>Vertebrate  </strong>, a free, fully standards-compliant CSS template designed by FreeCssTemplates<a href="http://www.nodethirtythree.com/"></a> for <a href="http://www.freecsstemplates.org/"> CSS Templates</a>.  This free template is released under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> license, so you’re pretty much free to do whatever you want with it (even use it commercially) provided you keep the links in the footer intact. Aside from that, have fun with it :)</p>
					<p>Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum ipsum. Proin imperdiet est. Phasellus dapibus semper urna. Pellentesque ornare, orci in felis. Donec ut ante. In id eros. Suspendisse lacus turpis, cursus egestas at sem.</p>
					<p class="links"><a href="#">Read More</a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;<a href="#">Comments</a></p>
				</div>
			</div>
			<div class="post">
				<h2 class="title"><a href="#">Lorem ipsum sed aliquam</a></h2>
				<p class="meta"><span class="date">September 10, 2009</span><span class="posted">Posted by <a href="#">Someone</a></span></p>
				<div style="clear: both;">&nbsp;</div>
				<div class="entry">
					<p>Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer. Donec ipsum. Proin imperdiet est. Phasellus <a href="#">dapibus semper urna</a>. Pellentesque ornare, orci in consectetuer hendrerit, urna elit eleifend nunc, ut consectetuer nisl felis ac diam. Etiam non felis. Donec ut ante. In id eros. Suspendisse lacus turpis, cursus egestas at sem.  Mauris quam enim, molestie in, rhoncus ut, lobortis a, est.</p>
					<p>Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum ipsum. Proin imperdiet est. Phasellus dapibus semper urna. Pellentesque ornare, orci in felis. Donec ut ante. In id eros. Suspendisse lacus turpis, cursus egestas at sem.</p>
					<p class="links"><a href="#">Read More</a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;<a href="#">Comments</a></p>
				</div>
			</div>
			<div class="post">
				<h2 class="title"><a href="#">Consecteteur hendrerit </a></h2>
				<p class="meta"><span class="date">September 10, 2009</span><span class="posted">Posted by <a href="#">Someone</a></span></p>
				<div style="clear: both;">&nbsp;</div>
				<div class="entry">
					<p>Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer. Donec ipsum. Proin imperdiet est. Phasellus <a href="#">dapibus semper urna</a>. Pellentesque ornare, orci in consectetuer hendrerit, urna elit eleifend nunc, ut consectetuer nisl felis ac diam. Etiam non felis. Donec ut ante. In id eros. Suspendisse lacus turpis, cursus egestas at sem.  Mauris quam enim, molestie in, rhoncus ut, lobortis a, est.</p>
					<p class="links"><a href="#">Read More</a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;<a href="#">Comments</a></p>
				</div>
			</div>
		<div style="clear: both;">&nbsp;</div>
		</div>
		<!-- end #content -->
		<div id="sidebar">
			<ul>
				<li>
					<div id="search" >
					<form method="get" action="#">
						<div>
							<input type="text" name="s" id="search-text" value="" />
							<input type="submit" id="search-submit" value="GO" />
						</div>
					</form>
					</div>
					<div style="clear: both;">&nbsp;</div>
				</li>
				<li>
					<h2>Aliquam tempus</h2>
					<p>Mauris vitae nisl nec metus placerat perdiet est. Phasellus dapibus semper consectetuer hendrerit.</p>
				</li>
				<li>
					<h2>Categories</h2>
					<ul>
						<li><a href="#">Aliquam libero</a></li>
						<li><a href="#">Consectetuer adipiscing elit</a></li>
						<li><a href="#">Metus aliquam pellentesque</a></li>
						<li><a href="#">Suspendisse iaculis mauris</a></li>
						<li><a href="#">Urnanet non molestie semper</a></li>
						<li><a href="#">Proin gravida orci porttitor</a></li>
					</ul>
				</li>
				<li>
					<h2>Blogroll</h2>
					<ul>
						<li><a href="#">Aliquam libero</a></li>
						<li><a href="#">Consectetuer adipiscing elit</a></li>
						<li><a href="#">Metus aliquam pellentesque</a></li>
						<li><a href="#">Suspendisse iaculis mauris</a></li>
						<li><a href="#">Urnanet non molestie semper</a></li>
						<li><a href="#">Proin gravida orci porttitor</a></li>
					</ul>
				</li>
				<li>
					<h2>Archives</h2>
					<ul>
						<li><a href="#">Aliquam libero</a></li>
						<li><a href="#">Consectetuer adipiscing elit</a></li>
						<li><a href="#">Metus aliquam pellentesque</a></li>
						<li><a href="#">Suspendisse iaculis mauris</a></li>
						<li><a href="#">Urnanet non molestie semper</a></li>
						<li><a href="#">Proin gravida orci porttitor</a></li>
					</ul>
				</li>
			</ul>
		</div>
		<!-- end #sidebar -->
		<div style="clear: both;">&nbsp;</div>
	</div>
	</div>
	</div>
 
	<!-- end #page -->
</div>
	<div id="footer">
		<p>Copyright (c) 2008 Sitename.com. All rights reserved. Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
	</div>
	<!-- end #footer -->
</body>
 
</html>
Et voici le fichier "style" attaché au template:

Code :
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
 
/*
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
*/
 
body {
	margin: 0;
	padding: 0;
	background: #FFFDEA url(images/img01.jpg) repeat-x left top;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #464032;
}
 
h1, h2, h3 {
	margin: 0;
	padding: 0;
	font-weight: normal;
	color: #333333;
}
 
h1 {
	font-size: 2em;
}
 
h2 {
	font-size: 2.4em;
}
 
h3 {
	font-size: 1.6em;
}
 
p, ul, ol {
	margin-top: 0;
	line-height: 180%;
}
 
ul, ol {
}
 
a {
	text-decoration: none;
	color: #9D151A;
}
 
a:hover {
}
 
#wrapper {
	width: 960px;
	margin: 0 auto;
	padding: 0;
}
 
/* Header */
 
#header {
	width: 940px;
	height: 148px;
	margin: 0 auto;
}
 
/* Logo */
 
#logo {
	float: left;
	height: 90px;
	margin: 0;
	background: url(images/img04.jpg) no-repeat left top;
	padding-top: 30px;
	color: #000000;
}
 
#logo h1, #logo p {
	margin: 0;
	padding: 0;
}
 
#logo h1 {
	float: left;
	padding-left: 120px;
	letter-spacing: -1px;
	text-transform: lowercase;
	font-size: 3.8em;
}
 
#logo p {
	float: left;
	margin: 0;
	padding: 26px 0 0 10px;
	font: normal 14px Georgia, "Times New Roman", Times, serif;
	font-style: italic;
	color: #5E4E38;
} 
 
#logo p a {
	color: #5E4E38;
}
 
#logo a {
	border: none;
	background: none;
	text-decoration: none;
	color: #A83A01;
}
 
/* Search */
 
#search {
	float: right;
	width: 280px;
	height: 60px;
	padding: 20px 0px 0px 0px;
	background: #E9E3CB;
	border-bottom: 4px solid #FFFFFF;
}
 
#search form {
	height: 41px;
	margin: 0;
	padding: 10px 0 0 20px;
}
 
#search fieldset {
	margin: 0;
	padding: 0;
	border: none;
}
 
#search-text {
	width: 170px;
	padding: 6px 5px 2px 5px;
	border: none;
	background: #FFFFFF;
	text-transform: lowercase;
	font: normal 11px Arial, Helvetica, sans-serif;
	color: #464032;
}
 
#search-submit {
	width: 50px;
	height: 23px;
	border: 1px solid #AC9A79;
	background: #AC9A79;
	font-weight: bold;
	font-size: 10px;
	color: #FFFFFF;
}
 
/* Menu */
 
#menu {
	width: 940px;
	height: 36px;
	margin: 0 auto;
	padding: 0;
}
 
#menu ul {
	margin: 0px 0px 0px 10px;
	padding: 0;
	list-style: none;
	line-height: normal;
}
 
#menu li {
	float: left;
}
 
#menu a {
	display: block;
	height: 26px;
	margin-right: 2px;
	margin-bottom: 10px;
	padding: 10px 20px 0px 20px;
	text-decoration: none;
	text-align: center;
	text-transform: uppercase;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 11px;
	font-weight: bold;
	color: #FFFFFF;
	border: none;
}
 
#menu a:hover, #menu .current_page_item a {
	background: #FFFFFF;
	text-decoration: none;
	color: #333333;
}
 
#menu .current_page_item a {
	background: #FFFFFF;
	color: #333333;
}
 
/* Page */
 
#page {
	width: 940px;
	margin: 0 auto;
	padding: 0;
}
 
#page-bgtop {
	padding: 20px px;
}
 
#page-bgbtm {
}
 
/* Content */
 
#content {
	float: right;
	width: 620px;
	padding: 30px 0px 0px 0px;
}
 
.post {
	margin-bottom: 15px;
}
 
.post-bgtop {
}
 
.post-bgbtm {
}
 
.post .title {
	margin-bottom: 10px;
	padding: 12px 0 0 0px;
	letter-spacing: -1px;
	color: #000000;
}
 
.post .title a {
	text-transform: lowercase;
	color: #333333;
	border: none;
}
 
.post .meta {
	height: 30px;
	background: url(images/img03.jpg) no-repeat left top;
	margin: 0px;
	padding: 0px 20px 0px 20px;
	text-align: left;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 13px;
	font-weight: bold;
}
 
.post .meta .date {
	float: left;
	height: 24px;
	padding: 3px 0px;
	color: #FFFFFF;
}
 
.post .meta .posted {
	float: right;
	height: 24px;
	padding: 3px 15px;
	border-left: 1px solid #FFFFFF;
	color: #FFFFFF;
}
 
.post .meta a {
	color: #FFFFFF;
}
 
.post .entry {
	padding: 0px 0px 20px 0px;
	padding-bottom: 20px;
	text-align: justify;
}
 
.links {
	padding-top: 20px;
	font-size: 12px;
	font-weight: bold;
}
 
/* Sidebar */
 
#sidebar {
	float: left;
	width: 280px;
	padding: 0px;
	color: #787878;
}
 
#sidebar ul {
	margin: 0;
	padding: 0;
	list-style: none;
}
 
#sidebar li {
	margin: 0;
	padding: 0;
	border-right: 1px solid #E9E3CB;
}
 
#sidebar li ul {
	margin: 0px 0px;
	padding-bottom: 30px;
}
 
#sidebar li li {
	line-height: 35px;
	border-bottom: 1px dotted #E5E0C6;
	margin: 0px 30px;
	border-right: none;
}
 
#sidebar li li span {
	display: block;
	margin-top: -20px;
	padding: 0;
	font-size: 11px;
	font-style: italic;
}
 
#sidebar h2 {
	background: url(images/img02.jpg) no-repeat left top;
	padding-left: 30px;
	padding-top: 6px;
	padding-bottom: 6px;
	letter-spacing: -.5px;
	font-size: 16px;
	font-weight: bold;
	color: #FFFFFF;
}
 
#sidebar p {
	margin: 0 0px;
	padding: 10px 30px 20px 30px;
	text-align: justify;
}
 
#sidebar a {
	border: none;
	color: #464032;
}
 
#sidebar a:hover {
	text-decoration: underline;
	color: #8A8A8A;
}
 
/* Calendar */
 
#calendar {
}
 
#calendar_wrap {
	padding: 20px;
}
 
#calendar table {
	width: 100%;
}
 
#calendar tbody td {
	text-align: center;
}
 
#calendar #next {
	text-align: right;
}
 
/* Footer */
 
#footer {
	width: 940px;
	height: 50px;
	margin: 0 auto;
	padding: 0px 0 15px 0;
	border-top: 4px solid #EBE6D1;
	font-family: Arial, Helvetica, sans-serif;
}
 
#footer p {
	margin: 0;
	padding-top: 20px;
	line-height: normal;
	font-size: 10px;
	text-transform: uppercase;
	text-align: center;
	color: #444444;
}
 
#footer a {
	color: #464032;
}
ab1609 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/03/2011, 10h09   #4
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 381
Points : 16 381
Ton problème est un problème HTML.
Revoit le code final obtenu.
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/03/2011, 10h11   #5
Invité de passage
 
Inscription : mars 2011
Messages : 10
Détails du profil
Informations forums :
Inscription : mars 2011
Messages : 10
Points : 1
Points : 1
Très bien merci, je vais chercher de ce côté .

Ce que je ne comprends pas, c'est que je peut sans problème ajouter du texte et conserver la mise en page.

Par contre le fait d'insérer le tableau php issu de ma requête entre les balises prévues, à la place du texte original du template, désorganise toute la mise en page. J'ai pourtant respecté la mise en forme d'origine (le menu de gauche se retrouve au milieu, le contenu de la page en dessous et le résultat de ma requête encore en dessous).

ab1609 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 14h51.


 
 
 
 
Partenaires

Hébergement Web