Hey

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.

Thanks

Member Avatar for 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

Member Avatar for diafol

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.