dongzu3511 2010-10-16 11:11
浏览 42
已采纳

PHP吐出事件的过程/位置/时间,结合结果在页面上创建项目存储与会话并创建购物车项目发送到paypal?

if(isset($_POST['submit'])){
    $eventSelect = $_POST['eventSelect'];
    $eventLocation = $_POST['eventLocation'];
    $eventDate = $_POST['eventDate'];

    echo "Event 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.

  • 写回答

1条回答 默认 最新

  • dtip91401 2010-10-16 11:54
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值