views:

76

answers:

2

I have a list of events for example I wanna show on a page with the users that have created them which is all in a table and the user who has created them's unique id, now if I wanna show their username and avatar I would have to run 100 queries inorder to show 100 events! but I'm sure their is a easier way I don;t know!

i have a table (user_table) with fields user_id INT(8) and user_photo VARCHAR(255) and I have another table (user_event_table) with event_id INT(8), event_user_id INT(8), event_details TEXT

so I want to show a list of all these events but I want to next to it show the user_photo !

+1  A: 
  1. Show us your tables, along with the query you're currently using, in a different question and people will help you with the SQL.

  2. Yes. Get the accurate current time at the start of your PHP script, and get the time at the end, and log the page name and the difference in times.

  3. If you're worried about this, you need to conduct a security audit of your scripts. There's no easy way to tell what someone who has access to your page's contents will leak.

  4. Again, you need a real security audit. Someone will have to read and understand all the code in order to be sure. There's no easy way.

Borealid
+2  A: 

Learn to join with SQL. It's fundamental to relational databases.

SELECT * FROM user_event_table uet
LEFT JOIN user_table ut
  ON ut.user_id = uet.user_id

Now each record will have a username and photo string.

Keyo