Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifying php variable after page load

Status
Not open for further replies.

monkle

Programmer
Joined
Feb 11, 2004
Messages
132
Location
US
I don't know if this is the place for this question or not. If it's not, please tell me where the appropriate place for it is. I'll try to sum up the question in one or two lines, and then I'll try to give as many details as I can.

Here is my question. Can I modify a php array after the page loads, and before the page passes the array to the next page? If so, how?

I am currently working on a shopping cart for an online store. I'm trying to do it with php and javascript, using cookies. It is broken down into two pages, one page to set the cookies, and one page to display the items in the cart.

The page that displays the items in the cart loads all of the items from the cookie into an array, and then runs a loop through the array to display the information.

Right now I'm trying to make it so that the user can modify the quantity of each item in their cart. Ideally I want the quantity to be in an editable textbox next to the item, and to save the changes in the texbox(es) when the user clicks on the button "Save Changes" at the bottom of the cart.

The only piece missing out of it is modifying the array before it is passed to the page that saves the cookie.

I've been looking for information on the subject for considerable time. Any input would be greatly apreciated.

To repeat the initial question again,

Can I modify a php array after the page loads, and before the page passes the array to the next page? If so, how?
 
I strongly suggest you look at PHP's session variables.

But you can only modify variables while the script is still running. A PHP script produces output then stops running. The browser just holds the visible output for the user to manipulate.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top