/    Sign up×
Community /Pin to ProfileBookmark

foreach output from db with $_SESSION

error_reporting(E_ALL | E_NOTICE);
ini_set(‘display_errors’, ‘1’);

Hello every1 im new to all of this so bare with me for any mistakes. :-).

I have an issue with getting my foreach ($_SESSION………. to output what the customer have ordered from the order page, so that when they go to the cash register, i would like to have the page show what they have ordered, before they just send the order, my code is this——–

<?php
if (isset ($_SESSION[‘basket]) && count($_SESSION[‘basket’]) > 0){
$sql = “SELECT * FROM order_product WHERE fk_order_ordre_id = ””;
$result = mysqli_query($connection, $sql) or die(mysqli_error($connection));

$ordre_id = mysqli_fetch_array($result);
echo “$order_id”;

foreach ($_SESSION[‘basket’] as $product_id => $product_amount){
$sql = “SELECT product_name, product_price FROM product WHERE fk_categori_id = ‘$order_id'”;
$result = mysqli_query($connection, $sql) or die(mysqli_error($connection));

[B]echo “I get this far, so just need to put something here for the output to work right??”;[/B]

}

?>
<?php
}
?>

i have tried almost everything from what i know and the web search results, but havent found a solution.

Best regards and thx in advance for any suggestions.

caramon

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmNov 21.2015 — I don't know what that first query is supposed to do for you. The where clause is confusing - like you left something out.

As for handling the query results that you are trying to do, you need to look up in the manual how the fetch function works. Check this out:

http://php.net/manual/en/mysqli-result.fetch-assoc.php
Copy linkTweet thisAlerts:
@caramonauthorNov 21.2015 — Ty ginerjm i try that
Copy linkTweet thisAlerts:
@ginerjmNov 21.2015 — In the future - you should try reading the manual before posting any questions here. It'll make you smarter and save others from doing your research for you. That's what programming is all about!
×

Success!

Help @caramon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...