Jump to content

Session array - losing data problem


Harley1979

Recommended Posts

Hi,

 

I'm having a problem with losing data for an array I have stored as a session. I need some help here.

 

Here is my code:

 

First page:

 

<?php

echo "

<form action='wholefoods-placeorder.php' method='post'>

<div id='tableContainer'>

<div id='tableContentHead'></div>

<div id='tableContentMain'>";

 

$mysqlCat = mysql_query("SELECT * FROM productCategory");

while($catRow = mysql_fetch_array($mysqlCat)){

$getCat = $catRow['category'];

echo "<h3 class='newfont'>{$getCat}</h3>";

 

$catID = $catRow['id'];

$mysqlProd = mysql_query("SELECT * FROM products WHERE categoryID = '$catID'");

echo "

<table>

<thead>

<tr>

<th class='i'>Product</th>

<th class='ii'>Size</th>

<th class='iii'>Price</th>

<th class='iv'>Qty</th>

</tr>

</thead>";

 

$i = 1;

while($prodRow = mysql_fetch_array($mysqlProd)){

echo "

<tbody>

<tr>

<td>".$prodRow['item']."</td>

<td>".$prodRow['size']."</td>

<td>£".$prodRow['price']."</td>

<td><input type='text' id='qty' name='qty[".$prodRow['id']."]' maxlength='1' size='1' /></td>

<input type='hidden' name='product[".$prodRow['item']."]' value='".$prodRow['item']."'></tr>

</tbody>";

}

 

echo "

<tfoot>

<tr>

<td colspan='4'></td>

</tfoot>

</table>";

}

 

echo "<input type='submit' id='submit' name='submit' value='Next' />

</div>

<div id='tableContentFoot'></div>

</form>"; ?>

 

Second page:

 

// set sessions

$_SESSION['qty'] = $_REQUEST['qty'];

$qty = $_SESSION['qty'];

//$product = $_REQUEST['product'];

 

foreach ($qty as $key => $value) {

if (isset($qty[$value])) {

echo $value.", ";

}

}

 

It seems to pick it up and write out on screen ok on the second page. It is after that when going to another url that it seems to lose the data.

 

I'm lost, any help would be great

 

Thanks

 

Harley

 

Link to comment
https://forums.phpfreaks.com/topic/52249-session-array-losing-data-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.