Get ID Of The Last Inserted Row

2 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€88.09
List Price:  €123.33
You save:  €35.24
£74.95
List Price:  £104.93
You save:  £29.98
CA$138.76
List Price:  CA$194.27
You save:  CA$55.51
A$156.34
List Price:  A$218.89
You save:  A$62.54
S$131.36
List Price:  S$183.92
You save:  S$52.55
HK$775.63
List Price:  HK$1,085.92
You save:  HK$310.28
CHF 82.97
List Price:  CHF 116.17
You save:  CHF 33.19
NOK kr1,042.97
List Price:  NOK kr1,460.20
You save:  NOK kr417.23
DKK kr657.56
List Price:  DKK kr920.61
You save:  DKK kr263.05
NZ$168.07
List Price:  NZ$235.31
You save:  NZ$67.23
د.إ367.27
List Price:  د.إ514.19
You save:  د.إ146.92
৳12,139.17
List Price:  ৳16,995.32
You save:  ৳4,856.15
₹8,502.43
List Price:  ₹11,903.74
You save:  ₹3,401.31
RM436.25
List Price:  RM610.77
You save:  RM174.52
₦160,949.90
List Price:  ₦225,336.30
You save:  ₦64,386.40
₨28,114.47
List Price:  ₨39,361.38
You save:  ₨11,246.91
฿3,363.01
List Price:  ฿4,708.35
You save:  ฿1,345.34
₺3,843.97
List Price:  ₺5,381.71
You save:  ₺1,537.74
B$568.99
List Price:  B$796.61
You save:  B$227.62
R1,866.07
List Price:  R2,612.58
You save:  R746.50
Лв172.18
List Price:  Лв241.06
You save:  Лв68.88
₩144,392.30
List Price:  ₩202,155
You save:  ₩57,762.69
₪363.07
List Price:  ₪508.32
You save:  ₪145.24
₱5,637.33
List Price:  ₱7,892.49
You save:  ₱2,255.16
¥14,345.18
List Price:  ¥20,083.82
You save:  ¥5,738.64
MX$1,953.82
List Price:  MX$2,735.42
You save:  MX$781.60
QR364.17
List Price:  QR509.85
You save:  QR145.68
P1,377.18
List Price:  P1,928.11
You save:  P550.92
KSh12,928.70
List Price:  KSh18,100.70
You save:  KSh5,172
E£5,082.28
List Price:  E£7,115.40
You save:  E£2,033.11
ብር13,334.03
List Price:  ብር18,668.17
You save:  ብር5,334.14
Kz91,740.82
List Price:  Kz128,440.82
You save:  Kz36,700
CLP$93,485.65
List Price:  CLP$130,883.65
You save:  CLP$37,398
CN¥728.69
List Price:  CN¥1,020.20
You save:  CN¥291.50
RD$5,909.76
List Price:  RD$8,273.90
You save:  RD$2,364.14
DA13,260.83
List Price:  DA18,565.70
You save:  DA5,304.86
FJ$225.87
List Price:  FJ$316.23
You save:  FJ$90.35
Q769.50
List Price:  Q1,077.34
You save:  Q307.83
GY$20,903.27
List Price:  GY$29,265.41
You save:  GY$8,362.14
ISK kr12,817.71
List Price:  ISK kr17,945.31
You save:  ISK kr5,127.60
DH926.83
List Price:  DH1,297.60
You save:  DH370.77
L1,712.89
List Price:  L2,398.12
You save:  L685.22
ден5,421.92
List Price:  ден7,590.91
You save:  ден2,168.98
MOP$798.27
List Price:  MOP$1,117.62
You save:  MOP$319.34
N$1,885.54
List Price:  N$2,639.83
You save:  N$754.29
C$3,676.59
List Price:  C$5,147.38
You save:  C$1,470.78
रु13,646.12
List Price:  रु19,105.12
You save:  रु5,458.99
S/366.98
List Price:  S/513.78
You save:  S/146.80
K407.70
List Price:  K570.80
You save:  K163.10
SAR375.08
List Price:  SAR525.13
You save:  SAR150.04
ZK2,789.96
List Price:  ZK3,906.06
You save:  ZK1,116.09
L438.55
List Price:  L613.99
You save:  L175.44
Kč2,200.28
List Price:  Kč3,080.48
You save:  Kč880.20
Ft35,707.16
List Price:  Ft49,991.45
You save:  Ft14,284.29
SEK kr968.20
List Price:  SEK kr1,355.51
You save:  SEK kr387.31
ARS$116,862.79
List Price:  ARS$163,612.59
You save:  ARS$46,749.79
Bs690.41
List Price:  Bs966.60
You save:  Bs276.19
COP$426,678.59
List Price:  COP$597,367.09
You save:  COP$170,688.50
₡50,572.20
List Price:  ₡70,803.11
You save:  ₡20,230.90
L2,590.19
List Price:  L3,626.37
You save:  L1,036.18
₲799,220.57
List Price:  ₲1,118,940.77
You save:  ₲319,720.20
$U4,176.41
List Price:  $U5,847.14
You save:  $U1,670.73
zł376.76
List Price:  zł527.49
You save:  zł150.72
Already have an account? Log In

Transcript

Hello, in this video, I am going to cover how to get the ID of the last inserted row. So what we've got here just insert a row and qaddafi the Sith Lord. So it's got a bunch of them here. And we want to get the ID. So this is useful for several different things. One, we might be inserting it then navigating to another page.

And for example, let's say to do, you're on a website, you are blogging, or it's a blog website, you click enter, or you click Submit, for the blog post, and it's common practice for the website to take you to that new blog post has been successfully inserted. And it would based on the ID so you could have a blog post page, which takes maybe you know, a get variable that you're passing through, you know, the form would be done as an action and a method and then the data ID can be used to retrieve The data to get is really simple. All you do is a connection or you know, whatever the name of the connection is last insert ID function. And then that's it. We're going to assign that to last i do and i think that you just added a row ID, then dollar sign, like so.

And I will a new line tab there. So as you can see, it should be 13. So if I reload it, we get you have just added a new row with the ID of 13. We load as you can see right there, and if I keep reloading it will just keep incrementing it because he keeps adding rows. So that is how you get the ID of the last insert. wrote, you can do whatever you want with it.

You could send the user to another page, send that Id with the user. You could maybe insert that into another area of your database. Another table, for example. There's a lot of stuff you can do. You can retrieve the data from it. And yeah, planning stuff.

So thanks for watching any questions, feel free to pop me, you know a message and I look forward to seeing you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.