Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.