PHP spits out the course/location/time of event, combine results to create item store on page with session and create cart item to send to paypal?
if(isset($_POST['submit'])){
$eventSelect = $_POST['eventSelect'];
$eventLocation = $_POST['eventLocation'];
$eventDate = $_POST['eventDate'];
echo "Event开发者_如何学C Name:";echo $eventName;
echo "<br /><br />Event Location:";echo $eventLocation;
echo "<br /><br />From :"; echo $eventDate;
}
When a user goes to the site they are presented with a drop down that lists the Event, and updates based on selection. Is there a way I can give the result of this an item number that I can than have enter a simple php cart through a session_start and then be directed to paypal using a checkout button? Or should I add an item number to each item in the database? Since a user has to result in one of those results anyway? If I was to do that how would one call that last field after the query? Is that possible?
Sorry if this is redundant I'm not used to working with shopping carts.
Typically this is handled by the user of an auto_increment column in your database. For example:
CREATE TABLE `events` (
`id` int(10) unsigned not null auto_increment,
`name` varchar(50) not null,
`location` varchar(100) not null,
`date` datetime not null,
PRIMARY KEY(`id`)
) ENGINE=InnoDB;
INSERT INTO events (name, location, date) VALUES('Foo', 'Bar', '2010-07-10 00:00:00');
INSERT INTO events (name, location, date) VALUES('Baz', 'Foo', '2010-11-10 00:00:00');
SELECT * FROM events;
+----+------+----------+---------------------+
| id | name | location | date |
+----+------+----------+---------------------+
| 1 | Foo | Bar | 2010-07-10 00:00:00 |
| 2 | Baz | Foo | 2010-11-10 00:00:00 |
+----+------+----------+---------------------+
You can see that the database automatically assigned the value for id
. It will never give the same value to different events. This becomes a unique "event id" that you can save in a session.
精彩评论