error_22 Posted October 30, 2006 Share Posted October 30, 2006 Hi,I have a db table called "catlinks". There are three different columns in there (c_id, c_name, c_url). I also have another table called "sublinks" with the columns: s_id, s_name, s_url, s_cat.I want the values from these tables to show up like this:[code]<table><tr><td>Head links</td><td>Sublinks</td></tr><tr><td>headlink#1 (c_name)</td>sublink#1, sublink#2 (s_name with the c_cat value of c_id)</td></tr><tr><td>headlink#2 (c_name)</td>sublink#3, sublink#4 (s_name with the s_cat value of c_id)</td></tr>etc...</table>[/code]So I tried the following:[code]echo "<table>";$sql = "SELECT * FROM catlinks l LEFT JOIN sublinks s ON c_id=s_cat ORDER BY c_name, s.s_name";$result = mysql_query($sql) or die(mysql_error());while ($row = mysql_fetch_object($result)){<tr><td><? echo $row->c_name; ?></td><td><? echo $row->s_name; ?></td></tr>}echo "</table>";[/code]The problem is, when I echo the results, I get this:[img]http://www.octocomnetwork.com/result.png[/img]Any help would be greatly appreciated!Thanks in advanceNiklas Link to comment https://forums.phpfreaks.com/topic/25531-mixing-results-from-2-tables/ Share on other sites More sharing options...
error_22 Posted October 30, 2006 Author Share Posted October 30, 2006 Anyone? Link to comment https://forums.phpfreaks.com/topic/25531-mixing-results-from-2-tables/#findComment-116904 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.