--- Sinna Trade <[EMAIL PROTECTED]> wrote: > I am a Newbie in Php :) > I have a working pre-maid advertising script written in php. > I want to ad a kind of shopping cart function to my script. > When I start a search query, i get x results. I want to add a check > box to all of my results to be able to insert some of them into an > other table that can be seen by that visitor only. > After the visitor collects some of these results, he should be able to > forward the collected info in mail. After the mail is sent I want the > "cart" to be emptied. > I don't know where to start at! > I thought about transforming the result itself into a form that > forwards the information to my "cart"... (I already have the MySql > table for my cart..) > I don't even know what I should use: Php or Java? Should I store the > information temporarily or insert it into a database? > Can please anyone tell me where to start at?
PHP runs on the server so it is appropriate for communicating with the MySQL database on your server. Usually, Java runs as an applet on the browser (client) so it can't communicate with your MySQL database. Java Server Pages work like PHP but the coding is completely different. On a PHP group, of course we will tell you that PHP should be used instead of Java. Adding a shopping cart is not a simple upgrade to an existing script. It's not a newbie project. Right now we know nothing about your advertising script or just what it is that you will be adding to a cart. Most of the time a shopping cart stores quantities and product numbers in a session variable on the server. You could store it in a database and there are reasons for doing it that way as an alternative. How you plan to accept payment is also a significant factor since it is integrated with the shopping cart function. We don't even know what your table looks like. In terms of adding checkboxes to a list output, the whole thing would have to be in a <form> tag. The method should be "post" and the action should be the location of your PHP script that processes the form data. It might be the same script that is running to show the form with the checkboxes. If only one copy of each item is to be added, you can have just checkboxes with HTML like this: <input type='checkbox' name='item[]' value='12345'> where the 12345 is your product number for the item on that row. You would fill this value in from the code which creates the list and "knows" what each item is. When you process the inputs in PHP you will look at $_POST['item'] and find an array that contains elements for each checkbox selected. You can view it in PHP with a statement like: printf("<pre>%s</pre>", print_r($_POST, true)); (or use $_POST['item'] to narrow the output further). When writing to session variables, you must do so before any output is sent to the browser in the form of static HTML, or print or echo statements. All of this is rather general since we don't have a clear idea of exactly what you are doing. James