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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.