dov6891 2010-02-05 02:36
浏览 11
已采纳

如何取消设置会话以及从表中输入

i m adding an book detail in a page(book_detail.php), when i add book information ,i m also adding offers and addons via iframe( using lightwindow.js) related with that book and i saved their id;s in 2 session array. if someone add 2 addons and 3 offers related to that books, i store those addons_is and offer_id in session and when i fill the all detail regarding that book,on the same time i add addons_is and offer_id in the database in same row. like

book_id|book_name|book_price|book_addons|book_offers|
 1     | php     | 100      |10,11,     | 17,18,19

where 10,11 from table_addon where that addon detail is saved and 17,18,19 is from table_offers where offer details are saved

now my question is: if someone add 2 offers and 3 addons with their detail, and does not go to submit that page( means he does not add details of that book) and go back, then how do i delete that addons and offers from both of tables.means i want to reset session array as well as the entry from both of table , if someone comes again to add new book detail.

i can not reset session when use comes first time , because on adding addons via iframe , page refresh automatically, so it is not possible to reset session on page load

  • 写回答

1条回答 默认 最新

  • duanhemou9834 2010-02-05 02:51
    关注

    In terms of how to delete the database records, look into using transactions with MySQL. The idea is that you:

    • Start a transaction
    • Execute a series of DML statements (INSERT,UPDATE,DELETE...SELECT is also allowed)
    • Commit the transaction (make all changes permanent)

    At any point after starting the transaction, you can use ROLLBACK to undo the changes that were made since the transaction was started. However, once the entire transaction is committed (using COMMIT) it is final.


    In terms of deleting the session data in PHP, you can just unset it:

    unset($_SESSION[varname])
    

    HTH,

    -aj

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

报告相同问题?

悬赏问题

  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私