id receiver sender urgency_level action
1 Adam John Medium 0
2 Adam Doe High 0
3 Adam Smith Low 0
And the values of the urgency_level are:
High
Medium
Low
How do I show only one loop in this query:
$receiver = 'Adam';
$sender = 'xxx';
"SELECT * FROM urgent_message WHERE receiver = '$receiver' AND sender = '$sender' AND action = '0' GROUP BY
receiver ORDER BY id LIMIT 3"
I want to get specific values, which are High, Medium, Low, for each receiver who has taken messages sent form a sender. If there is no message from this sender there will be another message displayed. The code maybe confusing, because I not yet know how to code. I don’t want to create 3 tables for each level of urgency needs. I have no idea, but have to figure it out.
Try: [google]how to set up indexes in mysql[/google].
If you still do not understand then come back here or ask on the SQL forum, but as you are a new coder you can probably afford to leave this issue for a while. Sorry to muddy the waters.
Oh yeah, I hadn’t really noticed that – pretty obvious really. I think I probably imagined that was one of many different queries the OP would be putting in.
You don’t need to, there is basically nothing wrong with your table as far as I can see.
I was a bit confused by what you were getting vs what you wanted to display in Post #1 (which looks like you want some kind of table).
Why not spell out one question at a time, and we’ll help you devise the sql query to get that, and then if you need it, some strategies for how to have PHP build those SQL queries.
I mean you asked this:
Which was clear enough and I replied:
… but did you understand that? Did you try it, did it work? Did it behave as you expected?