display specific data from sql database in php with more than row of data

Issue

I’m a newbie and developing php laundry service.

im using SESSION for the login,

Im having trouble when a username add a laundry ticket 2 times, so it will create 2 ticket_id, for example, 1001 and 1002 in table TICKET. they are both different order, under same username.

so when I want to display for example, ticket_id,

i do

SELECT ticket_id FROM TICKET WHERE ticket_username=$username

problem is it will show both of ticket id 1001 and 1002 since they are from same username.

im stuck help me

Solution

At some point you would want to be able to retrieve all orders by a customer or do you not want a user to be able to create 2 orders at the same time?
Anyway, if you only want the first order just use limit

SELECT ticket_id FROM TICKET WHERE ticket_username=$username LIMIT 1;

But I think you need to be clear about whether two orders can be created and how you’re going to prevent if if they can’t.

Answered By – Steve

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published