killfall Posted August 7, 2008 Share Posted August 7, 2008 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 Quote Link to comment Share on other sites More sharing options...
elflacodepr Posted August 7, 2008 Share Posted August 7, 2008 you can use the JOIN or UNION statement. Quote Link to comment Share on other sites More sharing options...
killfall Posted August 8, 2008 Author Share Posted August 8, 2008 Perfect thanks alot Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.