why do I get 1 as id for all locations??

Hi, I'm trying to save all the details stored in the session in a table. This session holds ids of records in the carts table but as it holds just the name of location, I'm using for loop to try and find the id of each location. Here's my implementation:

Never mind, I fixed it.