Reputation: 17361
I'm a novice programmer in PHP.
I have a simple messaging site with users in one table and another table with messages:
(date, from user, to users, message, primary key, subject).
First of all, I'm not sure this is the right way to have messages stored, so please tell me.
What I'm confused about is the display of the messages.
I want the page script to:
Then, I'll display only the ones of the first dimension of the multidimensional array, and when clicked will display the rest of the messages (all the second dimensions of a multidimensional array) in another place.
If somebody could help me with these steps with some bits of code or links to a website that could help, please do so.
Upvotes: 1
Views: 81
Reputation: 2167
To expand on Halfer's answer, the issue is that you're trying to store multiple things in the "to users" column. So you'll end up with something like toUsers = 5,24,242. That is really hard to parse from a database.
Instead, take that column out of that table and create a new table called "Message Recipients" which has "message id, user_receiving". Then you can have multiple rows, and this table will look like:
1, 5
1, 24
1, 242
...
Upvotes: 2