Ik heb een pagina dat de voorpagina van een webshop moet worden met daarin 4 artikelen. De HTML is zo
bagger als wat dat weet ik maar daar gaat het nu even niet om. Vanuit een tblartikelen moet 4 tabellen gevuld worden. Elke tabel bevat de titel van 1 product, een afbeelding een prijs en een omschrijving.Ik heb while icm mysql_fetcharray in icm met SELECT * FROM artikelen LIMIT 1 dan wordt 1 tabel netjes gevuld
Wanneer ik Limit op 4 zet dan heb ik dat alles gevuld wordt echter dat werkt niet. Weet iemand welke techniek ik moet gebruiken om 4 tabellen te vullen met data uit een tblproducten dat elk een unieke ID_ARTIKELNUMMER heeft?



<?php
session_start();
ini_set('error_display', '1');
error_reporting('E_ALL');
?>
<?php
include_once('includes/connect_to_mysql.php');
?>
<doctype html public>
<html dir=ltr lang=nl>
<head>
<title>Onlinewinkel-24u</title>
<meta content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<link rel="stylesheet" type="text/css" href="index_files/stylesheet.css">
<meta name=generator content="MSHTML 8.00.6001.18876">
</head>
<body bottommargin=0 leftmargin=0 rightmargin=0 topmargin=0 marginheight="0" marginwidth="0">
<!-- header //-->
<table border=0 cellspacing=0 cellpadding=0 width=766 align=center height=580>
<tbody>
<tr>
<td height=92 background=index_files/index_02.jpg width=766></td>
</tr>
<tr>
<td height=42 background=index_files/index_04.jpg width=766>
<table border=0 cellSpacing=0 cellPadding=0 width="100%">
<tbody>
<tr>
<td width=640><div style="padding-left: 15px"><a class=headerNavigation href="index.php">Home</a>
<img border=0 hspace=4 align=absMiddle src="index_files/nav_divider.gif" width=1 height=27>
<a class=headerNavigation href="shopping_cart.php">Winkelwagen</a> <img border=0 hspace=4 align=absMiddle
src="index_files/nav_divider.gif" width=1 height=27>
<a class=headerNavigation href="create_account.php">Klant worden</a><img border=0 hspace=4 align=absMiddle
src="index_files/nav_divider.gif" width=1 height=27> <a
class=headernavigation
href="login.php">Inloggen</A> <IMG border=0 hspace=4 align=absMiddle
src="index_files/nav_divider.gif" width=1 height=27> <a
class=headerNavigation
href="contact_us.php">Contact</a></div></td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
<td height=580 valign=top background=index_files/index_06.gif width=766><!-- header_eof //-->
<!-- body //-->
<table border=0 cellspacing=3 cellpadding=3 width="100%">
<tbody>
<tr>
<Td valign=top width=box_width><table border=0 cellSpacing=0 cellPadding=2 width=box_width>
<!-- left_navigation //-->
<!-- categories //-->
<tbody>
<tr>
<td height=28 background=index_files/info_header.gif><table border=0 cellSpacing=0 cellPadding=0 width="100%">
<tbody>
<tr>
<td class=infoBoxHeading height=14 width="100%">Categoriƫen</td>
<td class=infoBoxHeading height=14 noWrap><img border=0
alt="" src="index_files/pixel_trans.gif" width=11
height=14></td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
<td class=box_categories><table>
<tbody>
<tr>
<td><div style="padding-left: 10px" align=left>
<table class=infoBox border=0 cellSpacing=0
cellPadding=1 width="100%">
<tbody>
<tr>
<td><table class=infoBoxContents border=0
cellSpacing=0 cellPadding=3 width="100%">
<tbody>
<tr>
<td><img border=0 alt=""
src="index_files/pixel_trans.gif" width="100%"
height=1></td>
</tr>
<tr>
<td class=boxText>
<tr>
<td class=category_meny><img hspace=0 vspace=2
align=absMiddle
src="index_files/cat_arrow_right.gif">&nbsp;<A
class=category_link
href="index.php?cPath=36">Accessoires</A>
<tr>
<td class=category_meny><img hspace=0 vspace=2
align=absMiddle
src="index_files/cat_arrow_right.gif">&nbsp;<A
class=category_link
href="index.php?cPath=39">Accu's</A>
<tr>
<td class=category_meny><img hspace=0 vspace=2
align=absMiddle
src="index_files/cat_arrow_right.gif">&nbsp;<A
class=category_link
href="index.php?cPath=41">Handsfree</A>
<tr>
<td class=category_meny><img hspace=0 vspace=2
align=absMiddle
src="index_files/cat_arrow_right.gif">&nbsp;<a
class=category_link
href="index.php?cPath=40">Headset</A>
<tr>
<td class=category_meny><img hspace=0 vspace=2
align=absMiddle
src="index_files/cat_arrow_right.gif">&nbsp;<a
class=category_link
href="index.php?cPath=38">Hoesjes</a>
<tr>
<td class=category_meny><img hspace=0 vspace=2
align=absMiddle
src="index_files/cat_arrow_right.gif">&nbsp;<a
class=category_link
href="index.php?cPath=37">Opladers</a>
<tr>
<td class=category_meny><img hspace=0 vspace=2
align=absMiddle
src="index_files/cat_arrow_right.gif">&nbsp;<a
class=category_link
href="index.php?cPath=35">Telefoons</a></td>
</tr>
<tr>
<td><img border=0 alt=""
src="index_files/pixel_trans.gif" width="100%"
height=1></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</div>
<div style="padding-left: 28px" align=left><A
class=adv_searchlink
href="advanced_search.php">Uitgebreid
zoeken</a></div></td>
</tr>
</tbody>
</table>
<br></td>
</tr>
<tr>
<td height=5></td>
</tr>
<!-- categories_eof //-->
<!-- shopping_cart //-->
<tr>
<td height=28 background=index_files/info_header.gif><table border=0 cellSpacing=0 cellPadding=0 width="100%">
<tbody>
<tr>
<td class=infoBoxHeading height=14
width="100%">Winkelwagen</TD>
</tr>
</tbody>
</table></td>
</tr>
<tr>
<td class=box_cart><div style="margin: 10px; width: 135px">
<table class=infoBox border=0 cellSpacing=0 cellPadding=1
width="100%">
<tbody>
<tr>
<td><table class=infoBoxContents border=0 cellSpacing=0
cellPadding=3 width="100%">
<tbody>
<tr>
<td><img border=0 alt=""
src="index_files/pixel_trans.gif" width="100%"
height=1></td>
</tr>
<tr>
<td class=boxText><center>
Geen artikelen
</center></TD>
</tr>
<tr>
<td><img border=0 alt=""
src="index_files/pixel_trans.gif" width="100%"
height=1></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</div>
<tr>
<td height=5></td>
</tr>
<!-- shopping_cart_eof //-->
<tr>
<td height=28 background=index_files/info_header.gif><table border=0 cellSpacing=0 cellPadding=0 width="100%">
<tbody>
<tr>
<td class=infoBoxHeading height=14
width="100%">Informatie</TD>
<td class=infoBoxHeading height=14 noWrap><img border=0
alt="" src="index_files/pixel_trans.gif" width=11
height=14></td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
<td class=box_info><table class=infoBox border=0 cellSpacing=0 cellPadding=1
width="100%">
<tbody>
<tr>
<td><table class=infoBoxContents border=0 cellSpacing=0
cellPadding=3 width="100%">
<tbody>
<tr>
<td><img border=0 alt=""
src="index_files/pixel_trans.gif" width="100%"
height=1></td>
</tr>
<tr>
<td class=boxText><img
src="index_files/cat_arrow_right.gif">&nbsp;<a
href="information.php?info_id=11">Over
de iPhone</a><br>
<img src="index_files/cat_arrow_right.gif">&nbsp;
<a href="information.php?info_id=13">Meest gestelde vragen</a><br>
<img src="index_files/cat_arrow_right.gif">&nbsp;
<a href="information.php?info_id=15">Voorwaarden</a><br>
<img src="index_files/cat_arrow_right.gif">&nbsp;<a
href="information.php?info_id=16">Over ons bedrijf</a><br>
<img src="index_files/cat_arrow_right.gif">&nbsp;
<a href="information.php?info_id=17">test</a><br>
<img hspace=0 vspace=2 align=left
src="index_files/cat_arrow_right.gif">&nbsp;<A
href="contact_us.php">Contact</a></td>
</tr>
<tr>
<td><img border=0 alt=""
src="index_files/pixel_trans.gif" width="100%"
height=1></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
<center>
<br>
<img
src="index_files/logos_algemeen.jpg"><br>
<br>
</center></td>
</tr>
<!-- information_eof //-->
<!-- left_navigation_eof //-->
</tbody>
</table></td>
<!-- body_text //-->
<td valign=top width="100%"><table border=0 cellSpacing=0 cellPadding=0 width="100%">
<tbody>
<tr>
<td><table class=infoBox_voor border=0 cellSpacing=1 cellPadding=4
width="98%" align=center>
<tbody>
<tr>
<td class=main><?php echo $dynamischeTekst; ?></td>
</tr>
</tbody>
</table>
<br>
<!-- new_products //-->
<table class=infoBox border=0 cellSpacing=0 cellPadding=1 width="100%">
<tbody>
<tr>
<td><table class=infoBoxContents border=0 cellSpacing=0 cellPadding=0 width="100%">
<tbody>
<tr>
<td class=smallText vAlign=top align=left><div
style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px">
<table class=box_outline border=0 cellSpacing=3
cellPadding=0 width=278 height=160>
<tbody>
<?php
$rsProducten = mysql_query("SELECT * FROM tblartikelen LIMIT 1 ", $intDb);
if(!rsProducten)
die("De SQL opdracht klopt niet");

while($rProducten = mysql_fetch_array($rsProducten))
{
?>
<tr>
<td bgColor=#ebebeb height=30 vAlign=center
colSpan=2><a class=box_name
href="product_info.php?products_id=39"><?php echo($rProducten['Artikelnaam']); ?></a></td>
</tr>
<tr>
<td vAlign=center width=115 align=middle><a
href="product_info.php?products_id=39"><img
title="" border=0
alt=""
src="index_files/<?php echo($rProducten['Afbeelding']); ?>.jpg" width=100
height=80></A></td>
<td background=index_files/box_back.gif><table border=0 width="100%" height=121>
<tbody>
<tr>
<td class=box_desc vAlign=top colSpan=2
align=left><div
style="padding-right: 10px; padding-top: 7px"><?php echo($rProducten['Omschrijving']); ?></div></td>
</tr>
<tr>
<td class=box_price height=40 vAlign=center
width=60 align=middle><?php echo($rProducten['Prijs']); ?></TD>
<td vAlign=center><A
href="product_info.php?products_id=39"><img
border=0 alt=""
src="index_files/button_buy_now.gif" width=57
height=16></a></td>
</tr>
<?php
}
mysql_free_result($rsProducten);
mysql_close($intDb);
//einde while
?>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</div></td>
<td class=smallText vAlign=top align=left><div
style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px">

<table class=box_outline border=0 cellSpacing=3
cellPadding=0 width=278 height=160>
<tbody>
<tr>
<td bgColor=#ebebeb height=30 vAlign=center
colSpan=2><a class=box_name
href="product_info.php?products_id=35"></a></td>
</tr>
<tr>
<td valign=center width=115 align=middle><a
href="product_info.php?products_id=35"><img
title="" border="0"
alt=""
src="index_files/.jpg" width=100
height=80></a></td>
<td background=index_files/box_back.gif><table border=0 width="100%" height=121>
<tbody>
<tr>
<td class=box_desc vAlign=top colSpan=2
align=left><div
style="padding-right: 10px; padding-top: 7px"></div></td>
</tr>
<tr>
<td class=box_price height=40 vAlign=center
width=60 align=middle></td>
<td vAlign=center><a
href="product_info.php?products_id=35"><img
border=0 alt=""
src="index_files/button_buy_now.gif" width=57
height=16></a></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</div></td>
</tr>
<tr>
<td class=smallText vAlign=top align=left><div
style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px">
<table class=box_outline border=0 cellSpacing=3
cellPadding=0 width=278 height=160>
<tbody>
<tr>
<td bgColor=#ebebeb height=30 vAlign=center
colSpan=2><a class=box_name
href="product_info.php?products_id=37"></a></td>
</tr>
<tr>
<td valign=center width=115 align=middle>
<a href="product_info.php?products_id=37">
<img title="" border=0 alt="" src="index_files/.jpg" width=100 height=80></a></td>
<td background=index_files/box_back.gif><table border=0 width="100%" height=121>
<tbody>
<tr>
<td class=box_desc vAlign=top colSpan=2 align=left>
<div style="padding-right: 10px; padding-top: 7px"></div></td>
</tr>
<tr>
<td class=box_price height=40 vAlign=center
width=60 align=middle></td>
<td vAlign=center><a
href="product_info.php?products_id=37"><img
border=0 alt=""
src="index_files/button_buy_now.gif" width=57
height=16></a></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</div></td>
<td class=smallText vAlign=top align=left><div
style="padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px">
<table class=box_outline border=0 cellSpacing=3
cellPadding=0 width=278 height=160>
<tbody>
<tr>
<td bgColor=#ebebeb height=30 valign=center
colSpan=2><a class=box_name
href="product_info.php?products_id=36"></a></td>
</tr>
<tr>
<td valign=center width=115 align=middle>
<a href="product_info.php?products_id=36"><img
title="" border=0 alt="" src="index_files/.jpg" width=100
height=80></a></td>
<td background=index_files/box_back.gif><table border=0 width="100%" height=121>
<tbody>
<tr>
<td class=box_desc valign=top colSpan=2
align=left><div
style="padding-right: 10px; padding-top: 7px"></div></td>
</tr>
<tr>
<td class=box_price height=40 vAlign=center
width=60 align=middle></td>
<td vAlign=center><a
href="product_info.php?products_id=36"><img
border=0 alt=""
src="index_files/button_buy_now.gif" width=57
height=16></a></td>
</tr>

</tbody>
</table></td>
</tr>
</tbody>
</table>
</div></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
<!-- new_products_eof //-->
<br></td>
</tr>
</tbody>
</table></td>
<!-- body_text_eof //-->
</tr>
</tbody>
</table>
<!-- body_eof //-->
<!-- footer //--></td>
</tr>
<tr>
<td height=55 background=index_files/index_08.jpg width=954 colSpan=2><div style="padding-bottom: 0px; padding-right: 20px" class=footerText
align=right>Online-24u | <a
href="conditions.php">Algemene
voorwaarden</A> - <A
href="privacy.php">Privacybeleid</a> </div></td>
</tr>
</tbody>
</table>
<br>
<!-- footer_eof //-->
<br>
</body>
</html>
Hoeveel rijen krijg je terug en wat wil je precies met die rijen doen? Je wil het in een tabel zetten (of meerdere tabellen), maar wat is het probleem daarmee?
Je gebruikt dus een tabel om een product met afbeelding, prijs en omschrijving te tonen. In totaal
zijn hiervoor 4 <table> tags in de pagina. Kun je dan met 1 while lus al die tabellen vullen?
Antwoord is ja, vraag is alleen nog even hoe.

Heb je per product een tabel, of heb je per kenmerk een tabel?
Per product een tabel.
Als het per product is dan is het kinderlijk eenvoudig:
<?php
while ($row = mysql_fetch_array($strArtikelen)){
echo '<table>';
echo '<tr>';
echo '<td>'.$row['afbeelding'].'</td>';
echo '<td>'.$row['prijs'].'</td>';
echo '<td>'.$row['omschrijving'].'</td>';
echo '</tr>';
echo '</table>';
}
?>
Let alleen op dat ik je while conditie iets heb aangepast naar while ($row = mysql_fetch_array($strArtikelen)){
($row ipv $strArtikelen). Je query uitkomst had nu dezelfde variabele als de rij met gegevens, dat leek me niet echt handig...
En Niels kan je even je start topic aanpassen, haal de al de html eruit.

Reageren