Accolade Posted November 12, 2012 Share Posted November 12, 2012 Link to comment https://forums.phpfreaks.com/topic/270577-php-unable-to-increment-any-value-but-the-last-added-to-the-array/ Share on other sites More sharing options...
Accolade Posted November 12, 2012 Author Share Posted November 12, 2012 Anyone? Link to comment https://forums.phpfreaks.com/topic/270577-php-unable-to-increment-any-value-but-the-last-added-to-the-array/#findComment-1391768 Share on other sites More sharing options...
jcbones Posted November 12, 2012 Share Posted November 12, 2012 Are you getting the correct comic id's on your links? Link to comment https://forums.phpfreaks.com/topic/270577-php-unable-to-increment-any-value-but-the-last-added-to-the-array/#findComment-1391770 Share on other sites More sharing options...
Accolade Posted November 12, 2012 Author Share Posted November 12, 2012 Yes, everything is correct, except $qty is not updating correctly for any comic_id except the last one added. The URL action=add&comic_id is correct. Link to comment https://forums.phpfreaks.com/topic/270577-php-unable-to-increment-any-value-but-the-last-added-to-the-array/#findComment-1391771 Share on other sites More sharing options...
PFMaBiSmAd Posted November 12, 2012 Share Posted November 12, 2012 Your code that is setting $_SESSION['invoice'][$comic_id] is outside of and after the end of your loop. You would need to put in with the code that is fetching the data from the query result and setting the $name, $qty, and $price variables. Link to comment https://forums.phpfreaks.com/topic/270577-php-unable-to-increment-any-value-but-the-last-added-to-the-array/#findComment-1391772 Share on other sites More sharing options...
Accolade Posted November 12, 2012 Author Share Posted November 12, 2012 When changing foreach ($_SESSION['invoice'] as $value) { echo $value."<br>";} to.... foreach ($_SESSION['cart'] as $value) { echo $value."<br>";} The correct $qty and only the $qty is being outputted for each $comic_id in order. Link to comment https://forums.phpfreaks.com/topic/270577-php-unable-to-increment-any-value-but-the-last-added-to-the-array/#findComment-1391774 Share on other sites More sharing options...
Accolade Posted November 12, 2012 Author Share Posted November 12, 2012 Thank you PFMaBiSmAd Link to comment https://forums.phpfreaks.com/topic/270577-php-unable-to-increment-any-value-but-the-last-added-to-the-array/#findComment-1391776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.