Jump to content

[SOLVED] SELECT Multiple Tables


killfall

Recommended Posts

Hi there,

I have made a website which is based on blogs. Each blog is stored in a seperate table with the fields "id, time, date, blog, image_id" then I have another table called image which has links to all the images used in the blog and then has and image id in which the blog image id refers to. I want to make a query which uses an array to got more than 1 blog (2 at a time) but looks in both tables, the blog table for the blog itself, then the images table for the corresponding image.

 

The code I have now uses the printf() function but I have done it wrong and am not sure whats wrong or right or what.

<?$
query = mysql_query("SELECT *.favourite, link.image, image_id.image FROM favourite, image WHERE image_id.favourite=image_id.image ORDER BY date.favourite DESC") or die(Error);
while ($row = mysql_fetch_array($query, MYSQL_BOTH)) {
printf("<table width='100%%'  border='0' cellspacing='0'><tr><td width='50%%'>%s</td><td width='50%%'>%s</td></tr><tr><td colspan='2'>%s<a href='%s'><img src='%s' width='50' height='50' align='right'></a></td></tr></table>", $row["time.favourite"], $row["date.favourite"], $row["blog.favourite"], $row["link.favourite"], $row["link.image"]);
}
mysql_free_result($query);
?>

*favourite being the blog table BTW

Link to comment
https://forums.phpfreaks.com/topic/118704-solved-select-multiple-tables/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.