Hallo, ik heb dit:

$winkelmandje=array();
$winkelmandje = $_SESSION['winkelmand'];
$winkelmandje[$ID] = array("Naam" => $Naam,"Totaalprijs"=> $Totaalprijs);
$_SESSION['winkelmand'] = $winkelmandje;

En op winkelwagen.php lees ik het dan uit door:


print_r($_SESSION['winkelmand']);

dat werkt dan krijg ik dit:

Array ( [1] => Array ( [Naam] => Mister X [Totaalprijs] => 24 ) )

Maar nou wil ik dit dus netjes in een tabel zetten, dus moet ik de array apart uitlezen, dus de $ID apart enzo, weet iemand hoe dit moet? ik kom er niet meer uit
Ik zei niks hoor(ik typte alleen hahahahah);
jajaj, ok ok :P
greedyxl schreef op 13.10.2004 19:52
zo:

<?php
$mandje=$_SESSION['winkelmand']);


foreach ($mandje as $key => $value) {
echo $key': '.$value.'<br>';
}
?>
zo kan het volgens mij.


<?php
foreach($_SESSION['winkelmand'] as $mandje)
foreach($mandje as $key => $value)
echo $key . ' geeft ' . $value . '<br />';
?>
hey, dit werkt perfect man :D, alleen nog een probleempje hij echo'd $ID niet? hoe kan ik zorgen dat ie dat wel doet?
hehe je zeurt nogal he? :P

Wat geeft ie psies terug?
wacht ik heb het al in voegtoe.php:

$winkelmandje[$ID] = array("ID" => $ID, "Naam" => $Naam,"Totaalprijs"=> $Totaalprijs);

nog ff erin zetten :D
Nu doet ie het perfect, bedankt allemaal.

Zeurde ik zo erg?? :P
Dus het script werkte wel, alleen jij deed het niet goed :P

En ja, je zeurde ;)
Nou moet ik toch even terugkomen hierop, dit werkt wel maar ik wil dus van bijvoorbeeld ID 1 de daarbij behorende Naam en totaalprijs in aparte cellen laten zien in deze code:

echo"<tr>
<td bgcolor='#CCD1DE' width='17%' align='center'><b><font face='Arial' size='1' color='#3A4E7C'>
$ID</font></b></td>
<td bgcolor='#CCD1DE' width='11%' align='center'><b>
<font face='Arial' size='1' color='#3A4E7C'>$Naam</font></b></td>
<td bgcolor='#CCD1DE' width='10%' align='center'><b>
<font face='Arial' size='1' color='#3A4E7C'>$Maat</font></b></td>
<td bgcolor='#CCD1DE' width='10%' align='center'><b>
<font face='Arial' size='1' color='#3A4E7C'>$Aantal</font></b></td>
<td bgcolor='#CCD1DE' width='9%' align='center'><b>
<font face='Arial' size='1' color='#3A4E7C'>$Prijs</font></b></td>
<td bgcolor='#CCD1DE' width='20%' align='center'><b>
<font face='Arial' size='1' color='#3A4E7C'>$Voorbeeld</font></b></td>
<td bgcolor='#CCD1DE' width='19%' align='center'><b>
<font face='Arial' size='1' color='#3A4E7C'>$Totaalprijs</font></b></td>
</tr>";

Maar hoe kan dat met foreach? want dan zet ie het gewon achter elkaar zoals dit: 1MisterX15
NU doe ik het zo:

echo'<tr>

<td bgcolor="#CCD1DE" width="17%" align="center"><b><font face="Arial" size="1" color="#3A4E7C">
'.$key . ' geeft ' . $value . '/font></b></td>
<td bgcolor="#CCD1DE" width="11%" align="center"><b>
<font face="Arial" size="1" color="#3A4E7C"></font></b></td>
<td bgcolor="#CCD1DE" width="10%" align="center"><b>
<font face="Arial" size="1" color="#3A4E7C"></font></b></td>
<td bgcolor="#CCD1DE" width="10%" align="center"><b>
<font face="Arial" size="1" color="#3A4E7C"></font></b></td>
<td bgcolor="#CCD1DE" width="9%" align="center"><b>
<font face="Arial" size="1" color="#3A4E7C"></font></b></td>
<td bgcolor="#CCD1DE" width="20%" align="center"><b>
<font face="Arial" size="1" color="#3A4E7C"></font></b></td>
<td bgcolor="#CCD1DE" width="19%" align="center"><b>
<font face="Arial" size="1" color="#3A4E7C"></font></b></td>
</tr>';

Maar dan zet ie alle gegevens steeds in een nieuwe cel onder elkaar, en het moet naast elkaar... wie kan me aub helpen?

Reageren