Shopping cart application question
Shopping cart application question
am 04.04.2010 01:48:10 von ron.piggott
I am writing a shopping cart application. I am expanding the application
to have a store membership component.
Right now I am saving the customers selections in one of two ways:
- In the session variable "$_SESSION['order']" if they aren't logged in
- For those who have logged into their account I am saving their
selections in the table "membership_shopping_carts"
I have ran into trouble trying to output their choices under the "cart
contents" heading. I want to invoke one of two loops --- A 'while' loop
for the session variable and a mySQL query for the logged in users.
The " } else { " confuses PHP. I am not sure what I should be doing.
$_SESSION['user_reference'] stores the value of the logged in user. This
is how I tell if s/he is logged in or not --- and which loop I want to
invoke.
Suggestions?
Ron
if ( $_SESSION['user_reference'] > 0 ) {
$user_reference = $_SESSION['user_reference'];
$query = "SELECT `store_product_profile`.`reference` FROM
`membership_shopping_carts` INNER JOIN `store_product_profile` on
`store_product_profile`.`reference` =
`membership_shopping_carts`.`store_product_profile_reference ` WHERE
`membership_shopping_carts`.`member_reference` = $user_reference ORDER BY
`store_product_profile`.`product_name` ASC";
$shopping_cart_content_result=mysql_query($query);
$cart_records_found=mysql_numrows($shopping_cart_content_res ult);
$i=0;
while ( $i < $cart_records_found ) {
} else {
foreach ($_SESSION['order'] AS $key => $value ) {
}
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Shopping cart application question
am 04.04.2010 03:27:48 von Nilesh Govindrajan
I didn't understand your problem. Explain clearly.
--
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com
मà¥à¤°à¤¾ à¤à¤¾à¤°à¤¤ महान !
मम à¤à¤¾à¤°à¤¤: महतà¥à¤¤à¤® à¤à¤µà¤¤à¥ !
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Shopping cart application question
am 04.04.2010 05:36:05 von dmagick
> The " } else { " confuses PHP. =A0I am not sure what I should be doing.
You're missing at least one brace.
If the code you supplied is a copy of what you have, you're missing a
} for the end of the while loop and one for the end of the else
condition.
So it's treating } else { as part of the while construct (and while()
doesn't have anything like an else condition).
> if ( $_SESSION['user_reference'] > 0 ) {
> $i=3D0;
> while ( $i < $cart_records_found ) {
>
} // end while
> } else {
>
> foreach ($_SESSION['order'] AS $key =3D> $value ) {
>
> }
>
} // end else condition
--=20
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Shopping cart application question
am 04.04.2010 06:44:46 von ron.piggott
--=-YU1HBT1++yw1YRcscJP6
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
I have done something like you have said below Chris.
I put the code which is common to be loops in it's own file and I did an
INCLUDE
Ron
-----Original Message-----
From: chris smith
To: ron.piggott@actsministries.org
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Shopping cart application question
Date: Sun, 4 Apr 2010 13:36:05 +1000
> The " } else { " confuses PHP. I am not sure what I should be doing.
You're missing at least one brace.
If the code you supplied is a copy of what you have, you're missing a
} for the end of the while loop and one for the end of the else
condition.
So it's treating } else { as part of the while construct (and while()
doesn't have anything like an else condition).
> if ( $_SESSION['user_reference'] > 0 ) {
> $i=0;
> while ( $i < $cart_records_found ) {
>
} // end while
> } else {
>
> foreach ($_SESSION['order'] AS $key => $value ) {
>
> }
>
} // end else condition
--=-YU1HBT1++yw1YRcscJP6--