Am new to PHP need help, if I want to create a list, and only want to add an item one below the other what would be the best method in using Sessions. If there any examples that would really help.


6 Years
Discussion Span
Last Post by diafol

You're not making much sense. If you're talking about having a form to add to a list...

1) Add the data via a form - send it to a different file
2) The file accepts the data (via $_POST) - you then have a choice, you can add it to a MySQL DB for 'permanent addition' or keep it in a $_SESSION variable for temporary usage - probably best to use DB.


Thanks for the feedback, behaviour is like a shopping cart. choose an item I add it to my list. how can I store those list of items on the same page. Hope I have explained it a bit clearer


OK, you still have the option of storing data temporarily in sessions or 'permanently' in DB. You could use both of course, transferring session data -> DB on checkout or similar. However, using DB is probably the best method. You may also consider using Ajax (try jQuery) to add data to avoid page reload/refresh on every addition. In this case yoiu should use "progressive enhancement", meaning that a fallback mechanism exists (straight php/mysql) is an user has js turned off.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.