I have information in two tables in a database, which I would like to incorporate into 1 table on a web page. Within the database tables there are common aspects, 1 being email fields in both. How can I join these two tables and retrieve the information I require in the web page table?
In the following query you may get certain columns twice which are repeated twice in two tables. So, select columns individually like select table1.a, table1.b, table1.c, table1.emailID, table2.a1, table2.b1 from table1 inner join table2 on table1.emailID = table2.emailID Also, choose inner join or left/right join depending on what you want. If you want all rows from table1 irrespective of a matching email id in table2 then use 'left join' or If you want all rows from table2 irrespective of a matching email id in table1 then use 'right join' But, if you want only matching rows then use INNER JOIN. Hope this helps
Thanks for your invaluable assistance guys, that code got the script working perfectly. If you send me a PM through here, I'll show you my appreciation by sending the links to the 5 albums that my friend and I have recorded. The recordings play for six and a half hours, so should be something in there that you will enjoy.
It shouldn't be $row['upload_id'], but $result['upload_id'] Correspondingly change that in all places. --link_dev <td align=\"left\"><img src=\"pictures/{$row['upload_id']}\"/></td> <td align=\"left\">" . stripslashes($row['parkname']) . "</td> <td align=\"center\">" . stripslashes($row['parklocation']) . "</td> <td align=\"left\">" . stripslashes($row['caravandetails']) . "</td> </tr>\n";
If you could write error, It will be better to analyze. but I can't see while loop in that code. In above code you are executing query than using row$['fields'] but where did you define $row? Try something like this; $result = mysql_query ($query); while ($row = mysql_fetch_array($result)) { $ip = $row["upload_id"]; ... ... ... ... } Edit: I am a little bit late, link_dev answered first If your query returns 1 record you don't need a while loop as I write.