views:

501

answers:

1

Hello, I need to generate a list of activity from multiple tables in order of the date they were entered into the tables, but when i spit them out (with php), i want each result to look specific to a design that i have for each table.

ie...i have the tables: listings, photos, comments

-the results from listings should be designed a certain way, the results from photos should be designed a different way, the results from comments should be designed a third way

-i would like to mesh the results from all three tables into one date-ordered list

*i can pull the results with a mysql join, but i dont know how to alter the results according to the table

does this mack sense? i'm way lost!

+1  A: 

The process is this:

  • Query Database, get results back ordered by date
  • Iterate over results creating table, based on date/variable you will assign a CSS class to the current row you are creating. (use an if/switch/function etc. to figure out what class should be assigned)
  • After iteration is done complete the table / etc. and display.
Syntax
(use an if/switch/function etc. to figure out what class should be assigned)...i guess what i am missing is how do i tell which table the result came from? i can get the results from the column, but i dont know how to identify which table it was in...
johnnietheblack
When you query you can do something like this for a naming convention:SELECT myTable1.value1 as value1, myTable2.value2 as value2 FROM myTable1 LEFT JOIN myTable2 ON (myTable1.id=myTable2.id) ORDER BY myTable1.date; When you get your results you will have value1 and value2 instead of column names.
Syntax
Those results assume that you are going to use mysql_fetch_assoc or mysql_fetch_array for your results and not mysql_fetch_rows. You will need an associative array that you can read the key from to tell what result column you are working with.
Syntax
wordup, thanks syntax...im gonna go try that out:)
johnnietheblack