YourPadre Posted August 18, 2009 Report Share Posted August 18, 2009 (edited) Sveiki tauta :) Problēma tāda - Ir internetveikala checkout. Rupji sakot, lietotājs ievada par sevi datus un veic pasūtījumu. Pasūtāmās lietas atrodas sesijā. Tiko cilvēks uzspiež "Pasūtīt", viņa rekvezīti tiek pievienoti datu bāzes tabulai un citai tabulai vajag pievienot pasūtījumu ar rekvezītu id. Kā es varu dabūt šo rekvezītu id, kas ir tikko pievienoti datu bāzei? Ja grūti saparast, es centīšos savādāk noformulēt :) Edited August 18, 2009 by YourPadre Quote Link to comment Share on other sites More sharing options...
mickys Posted August 18, 2009 Report Share Posted August 18, 2009 http://www.w3schools.com/php/func_mysql_insert_id.asp Quote Link to comment Share on other sites More sharing options...
Indian Posted August 18, 2009 Report Share Posted August 18, 2009 $sql = "INSERT INTO rekviziti(`id`,`etc`) VALUES ..." $lastid = mysql_insert_id(); $sql2 = "INSERT INTO pasutijums(`rekvizita_id`,`etc`) VALUES ('$lastid','')"; Quote Link to comment Share on other sites More sharing options...
YourPadre Posted August 18, 2009 Author Report Share Posted August 18, 2009 $sql = "INSERT INTO rekviziti(`id`,`etc`) VALUES ..." $lastid = mysql_insert_id(); $sql2 = "INSERT INTO pasutijums(`rekvizita_id`,`etc`) VALUES ('$lastid','')"; Cik vienkārši! Paldies liels :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.