desithugg Posted November 5, 2006 Share Posted November 5, 2006 [code]<?$query = "SELECT categories.id,categories.name as c_name,categories.views,poems.id as poem_id,poems.name,poems.username from categories left join poems ON poems.category = categories.id"; $result = mysql_query($query) or die(mysql_error());while($row = mysql_fetch_array($result)){$count++;$id = $row['id'];$c_name = $row['c_name'];$c_views = $row['views'];$poem_id = $row['poem_id'];$name = $row['name'];$username = $row['username'];echo"<table class='top' align='center' width='80%'><tr><td class='top' width='25%' valign='top'>$c_name<br>Poems:112<br>Views:$c_views</td><td width='75%' class='top' align='left' valign='top'><div align='left'>Latest Poems:<br>-$name BY:$username<br></div></td></tr></table>";}?>[/code]Umm..I need help I want to make it so it only gets 5 poems.poem for each category i tried adding limit 5 at the end but than it only get 5 categories.name I want to display all categories.name and 5 poems.poem where poems.category = categories.id Link to comment https://forums.phpfreaks.com/topic/26236-join/ Share on other sites More sharing options...
Stooney Posted November 5, 2006 Share Posted November 5, 2006 as far as i know you'll need more than one query. such asselect poems from table where category=1 limit 5select poems from table where category=2 limit 5and so on...unless users set the categories, in which case one of the smarter people might have a solution. Link to comment https://forums.phpfreaks.com/topic/26236-join/#findComment-120014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.