bas007gsm
Gebruiker
- Lid geworden
- 4 jan 2002
- Berichten
- 394
Hoe kun je een database uitlezen, en zorgen dat de gegevens naast elkaar komen te staan?
Zo doe ik het in html en zou het er in php ook uit moeten zien:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table>
<tr>
<td height="400" rowspan="4"><img src="images/parket/QST001.jpg" width="125" height="165" /></td>
<td></td>
<td height="400" rowspan="4"><img src="images/parket/QST002.jpg" width="125" height="165" /></td>
</tr>
<tr>
<td bgcolor="#CCFF33">Merk</td>
<td></td>
<td bgcolor="#CCFF33">Merk</td>
</tr>
<tr>
<td>Serie</td>
<td></td>
<td>Serie</td>
</tr>
<tr>
<td valign="top">Kleur</td>
<td></td>
<td valign="top">Kleur</td>
</tr>
</table>
</body>
</html>
Dit is de php uitkomst nu, maar alles komt nu naast elkaar, ipv steeds 2 of 3 producten naast elkaar:
Zo doe ik het in html en zou het er in php ook uit moeten zien:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table>
<tr>
<td height="400" rowspan="4"><img src="images/parket/QST001.jpg" width="125" height="165" /></td>
<td></td>
<td height="400" rowspan="4"><img src="images/parket/QST002.jpg" width="125" height="165" /></td>
</tr>
<tr>
<td bgcolor="#CCFF33">Merk</td>
<td></td>
<td bgcolor="#CCFF33">Merk</td>
</tr>
<tr>
<td>Serie</td>
<td></td>
<td>Serie</td>
</tr>
<tr>
<td valign="top">Kleur</td>
<td></td>
<td valign="top">Kleur</td>
</tr>
</table>
</body>
</html>
Dit is de php uitkomst nu, maar alles komt nu naast elkaar, ipv steeds 2 of 3 producten naast elkaar:
PHP:
<?php
error_reporting(E_ALL);
include('connect.php');
//Load all variables from the database orders
$query = "SELECT * FROM producten ORDER BY id" or die ('FOUT : Query maken mislukt');
$result = mysql_query($query) or die (mysql_error());
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table border="1" align="center">
<?php
// put the variables from database products into a table
while (list($id, $merk, $serie, $kleurcode, $kleur, $lengte, $breedte, $hoogte, $prijs, $afbeelding) = mysql_fetch_row($result)){
echo("
<tr>
<td rowspan=5><img src=\"images/parket/$afbeelding.jpg\"></td>
</tr>
<tr>
<td>$merk, $kleurcode </td>
</tr>
<tr>
<td>$serie </td>
</tr>
<tr>
<td>$kleur</td>
</tr>
<tr>
<td><a href=\"details.php?id=$id\">details</a></td>
</tr>
");
}
?>
</table>
</body>
</html>