First post here. I am trying to display the most recent 5 records per page from my database from multiple tables on the home page of my web site.
My database is set up in a one to many relationship via the categories table. My table structures are set up as below:
categories table
--------------------------------------
catid(PK)
category
urlPath
General Info table
--------------------------------------
gid(PK)
catid
title
date_posted
date_reported
picURL
picALT
picTitle
article_body
How To Table
--------------------------------------
hid(PK)
catid
title
date_posted
date_reported
picURL
picALT
picTitle
article_body
Missions Table
--------------------------------------
mid(PK)
catid
title
date_posted
date_reported
picURL
picALT
picTitle
article_body
Projects Table
---------------------------------------
pid(PK)
catid
title
date_posted
date_reported
picURL
picALT
picTitle
article_body
I have set up my sql query as follows:
Code: Select all
$sqlCommand = mysql_query("(SELECT * FROM generalinfo) UNION (SELECT * FROM howto) UNION (SELECT * FROM missions) UNION (SELECT * FROM projects) ORDER BY reported_date DESC LIMIT $records, $per_page")or die(mysql_error());I have hit a snag where I'm not quite sure how to build the array to display the data from each table. Any advise on what methodology I should follow would be appreciated or if the UNION method used in the SQL above would be the best way of grabbing the data.
Best regards
Gerry