Mysql resultaten tabel > nieuwe regel
Code (php)
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
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
<?php
// Make a MySQL Connection
include "config.php"; //verbinding maken
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM dvds ORDER BY titel ASC")
or die(mysql_error());
$x=0;
echo "<TABLE width='583' border=0> <TR> <TD width=25% height='130'><tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result ).$x<8){
// Print out the contents of each row into a table
echo "<TABLE width='100%' height='130'><TR>";
echo "<TD><table width='120' border='0' align='center'>";
echo '<td height="130" bgcolor="#333333"><span class="box"><a href="film.php?id=';
echo $row['id'];
echo '">';
echo '<img src="covers/';
echo $row['id'];
echo '.jpg" alt="" width="90" height="125" border="0" /></a></span></td>';
echo '<td bgcolor="#333333" class="box2">';
echo $row['titel'];
echo '</td>';
echo '<td bgcolor="#333333" class="box2">';
echo $row['genre'];
echo '</td>';
echo "</table></TD>";
echo "</TR> </TABLE>";
echo "</TD> <TD>";
if($x == 3){
echo '</tr><tr >';
}
$x++;
}
echo "</TD></TR></TABLE>";
?>
// Make a MySQL Connection
include "config.php"; //verbinding maken
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM dvds ORDER BY titel ASC")
or die(mysql_error());
$x=0;
echo "<TABLE width='583' border=0> <TR> <TD width=25% height='130'><tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result ).$x<8){
// Print out the contents of each row into a table
echo "<TABLE width='100%' height='130'><TR>";
echo "<TD><table width='120' border='0' align='center'>";
echo '<td height="130" bgcolor="#333333"><span class="box"><a href="film.php?id=';
echo $row['id'];
echo '">';
echo '<img src="covers/';
echo $row['id'];
echo '.jpg" alt="" width="90" height="125" border="0" /></a></span></td>';
echo '<td bgcolor="#333333" class="box2">';
echo $row['titel'];
echo '</td>';
echo '<td bgcolor="#333333" class="box2">';
echo $row['genre'];
echo '</td>';
echo "</table></TD>";
echo "</TR> </TABLE>";
echo "</TD> <TD>";
if($x == 3){
echo '</tr><tr >';
}
$x++;
}
echo "</TD></TR></TABLE>";
?>
(niet getest) Maar dit lijkt me veel handiger.
Toch ook weer dat .$x<8 in die while he.. LAAT DAT NOU EENS! ÉÉN Conditie in een While.. in jou geval is die conditie $row=mysql_fetch_array
Ja.. sorry.. ik doe dat zelf ook nooit.. maar hij had het erin staan. En ik poste dat stukje code alleen maar om even te laten zien hoe het ook kan qua echo'en..
Code (php)
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
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
<?php
// Make a MySQL Connection
include "config.php"; //verbinding maken
$url1 = '<td height="130" bgcolor="#333333"><span class="box"><a href="film.php?id=';
$url2 = '">';
$url3 = '<img src="covers/';
$url4 = '.jpg" alt="" width="90" height="125" border="0" /></a></span></td>';
$url5 = '<td bgcolor="#333333" class="box2">';
$url6 = '</td>';
$url7 = '<td bgcolor="#333333" class="box2">';
$url8 = '</td>';
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM dvds ORDER BY titel ASC")
or die(mysql_error());
$x=0;
echo "<TABLE width='583' border=0> <TR> <TD width=25% height='130'>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result ))
{
// Print out the contents of each row into a table
echo "<TABLE width='100%' height='130'><TR>";
echo "<TD><table width='120' border='0' align='center'>";
echo "<tr>";
echo $url1;
echo $row['id'];
echo $url2;
echo $url3;
echo $row['id'];
echo $url4;
echo "</tr>";
echo "<tr>";
echo $url5;
echo $row['titel'];
echo $url6;
echo "</tr>";
echo "<tr>";
echo $url7;
echo $row['genre'];
echo $url8;
echo "</tr>";
echo "</table></TD>";
echo "</TR> </TABLE>";
echo "</TD> <TD>";
if($x == 3){
echo '</tr><tr >';
}
$x++;
}
echo "</TD></TR></TABLE>";
?>
// Make a MySQL Connection
include "config.php"; //verbinding maken
$url1 = '<td height="130" bgcolor="#333333"><span class="box"><a href="film.php?id=';
$url2 = '">';
$url3 = '<img src="covers/';
$url4 = '.jpg" alt="" width="90" height="125" border="0" /></a></span></td>';
$url5 = '<td bgcolor="#333333" class="box2">';
$url6 = '</td>';
$url7 = '<td bgcolor="#333333" class="box2">';
$url8 = '</td>';
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM dvds ORDER BY titel ASC")
or die(mysql_error());
$x=0;
echo "<TABLE width='583' border=0> <TR> <TD width=25% height='130'>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result ))
{
// Print out the contents of each row into a table
echo "<TABLE width='100%' height='130'><TR>";
echo "<TD><table width='120' border='0' align='center'>";
echo "<tr>";
echo $url1;
echo $row['id'];
echo $url2;
echo $url3;
echo $row['id'];
echo $url4;
echo "</tr>";
echo "<tr>";
echo $url5;
echo $row['titel'];
echo $url6;
echo "</tr>";
echo "<tr>";
echo $url7;
echo $row['genre'];
echo $url8;
echo "</tr>";
echo "</table></TD>";
echo "</TR> </TABLE>";
echo "</TD> <TD>";
if($x == 3){
echo '</tr><tr >';
}
$x++;
}
echo "</TD></TR></TABLE>";
?>
Geeft: http://collinkicken.nl/screen8.jpg
Hij hoeft alleen nog maar verder te gaan op de 2e rij.
@Eejee:
Ik weet dat ik raar programmeer :p Ik kan het ook bijna niet, tis knutselwerk.
in plaats van
if($x == 3)
Timen schreef op 07.11.2008 12:26:
if($x % 4 !=0)
in plaats van
if($x == 3)
in plaats van
if($x == 3)
Dat geeft: eerste rij: 2 items, tweede rij 1 item, 3e 1 etc.
Dan moet je hem in je if($x == 3) ook weer op 0 zetten.
Timen schreef op 07.11.2008 12:40:
Hmm precies hetzelfde resultaat.
Post nog even de code die je nu gebruikt...
En waarom gebruik je half variables en half echo. Want volgens mij sluit je de tabel of td niet goed af, maar ik kan het zo echt niet zien hoor.
Edit: Zo, dit lijkt me toch iets overzichtelijker ofniet?
Code (php)
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
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
<?php
// Make a MySQL Connection
include "config.php"; //verbinding maken
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM dvds ORDER BY titel ASC")
or die(mysql_error());
$x=0;
echo "<TABLE width='583' border=0><TR><TD width=25% height='130'>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result ))
{
// Print out the contents of each row into a table
?>
<TABLE width='100%' height='130'>
<TR>
<TD>
<table width='120' border='0' align='center'>
<tr>
<?php
echo '<td height="130" bgcolor="#333333"><span class="box"><a href="film.php?id='.$row['id'].'">';
echo '<img src="covers/'.$row['id'].'.jpg" alt="" width="90" height="125" border="0" /></a></span></td>';
echo '</tr><tr>';
echo '<td bgcolor="#333333" class="box2">'.$row['titel'].'</td>';
echo '</tr><tr>';
echo '<td bgcolor="#333333" class="box2">'.$row['genre'].'</td>';
?>
</tr>
</table>
</TD>
</TR>
</TABLE>
</TD>
<?php
if($x == 3){
echo '</tr><tr >';
}
$x++;
echo "<TD>";
}
echo "</TD></TR></TABLE>";
?>
// Make a MySQL Connection
include "config.php"; //verbinding maken
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM dvds ORDER BY titel ASC")
or die(mysql_error());
$x=0;
echo "<TABLE width='583' border=0><TR><TD width=25% height='130'>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result ))
{
// Print out the contents of each row into a table
?>
<TABLE width='100%' height='130'>
<TR>
<TD>
<table width='120' border='0' align='center'>
<tr>
<?php
echo '<td height="130" bgcolor="#333333"><span class="box"><a href="film.php?id='.$row['id'].'">';
echo '<img src="covers/'.$row['id'].'.jpg" alt="" width="90" height="125" border="0" /></a></span></td>';
echo '</tr><tr>';
echo '<td bgcolor="#333333" class="box2">'.$row['titel'].'</td>';
echo '</tr><tr>';
echo '<td bgcolor="#333333" class="box2">'.$row['genre'].'</td>';
?>
</tr>
</table>
</TD>
</TR>
</TABLE>
</TD>
<?php
if($x == 3){
echo '</tr><tr >';
}
$x++;
echo "<TD>";
}
echo "</TD></TR></TABLE>";
?>
Ik ga ervanuit dat je boven en onder dit script <html> en </html> hebt staan.
Zoals je nu beter kunt zien moet je de if ($x == 3) { tussen de </TD> en <TD> tag zetten. Zodat het in de goede volgorde staat.
Gewijzigd op 01/01/1970 01:00:00 door Steven Hack
wordt dan
Zoals al 5x vernoemd is... Lees wat er gepost wordt, neem het in je op, en voer het uit :-)
Gewijzigd op 01/01/1970 01:00:00 door Timen kut
Timen schreef op 07.11.2008 13:45:
Yeehaa! Bedankt allemaal, hij werkt!
Ik moest $x=0; veranderen naar $x=-1; anders stonden er 4 op de eerste rij daarna 3.
Thnx!