hi,
I have one cross join query in mysql as given below,
SELECT tblmodule.module_id,tblmodule.module_name,tblmodule.module_desc, tblmodule.module_priority, tblarticles.article_id,
tblarticles.article_title FROM tblmodule LEFT JOIN tblarticles ON tblmodule.module_id=tblarticles.article_module_id
WHERE tblmodule.module_type = 5 ORDER BY tblmodule.module_priority, tblarticles.article_id DESC;
module_name have one to many article_title . What I want to do is set the limit in sql query that it selects module_name and only six article_title.
Any way to set limit for article_title in this query or
if someone can do in php like one module_name and six of its article_titles.
At the minute I am using query and php is shown on bottom of page.
The result look like this
heading1
sub heading1 .1 sub heading1.2
sub heading1. 3 sub heading1.4
...................... ...................
...................... ...................
...................... ...................
heading2
sub heading2.1 sub heading2.2
sub heading 2.3 sub heading2.4
...................... ...................
...................... ...................
...................... ...................
But I want result that only one heading and its 6 sub headings like this
heading1
sub heading1 .1 sub heading1.2
sub heading1. 3 sub heading1.4
sub heading1. 5 sub heading1.6
heading2
sub heading2.1 sub heading2.2
sub heading 2.3 sub heading2.4
sub heading2.5 sub heading2.6
and so on
thnks for your help in advance
i am using query in php like this
$query3 = "SELECT tblmodule.module_id,tblmodule.module_name,tblmodule.module_desc, tblmodule.module_priority, tblarticles.article_id,
tblarticles.article_title FROM tblmodule LEFT JOIN tblarticles ON tblmodule.module_id=tblarticles.article_module_id
WHERE tblmodule.module_type = 5 ORDER BY tblmodule.module_priority, tblarticles.article_id DESC tblarticles.article_title LIMIT 6";
$result3 = do_query($query3, $dbcnx);
$heading;
$counter2=1;
$cells_per_row2=2;
?><tr><td>
<table width="100%" cellpadding="0" cellspacing="0"><?
while($row3 = mysql_fetch_array($result3))
{
if($heading!=$row3['0']){
if($counter2!=1) echo "<tr><td colspan=2><hr></td></tr>";
?>
<tr><td class="box_head"><a href="./index.php?do=box&id=<?=$row3['0']?>">
<font color="#FFFFFF"><?=$row3['1']?></font></a></td><td align="right"><img src="img/side.gif" /></td></tr>
<?
$heading=$row3['0'];
}
echo $heading;
$counter2++;
if(($counter2 % $cells_per_row2) == 0) { echo '<tr>'; } ?>
<td width="33%" id="pagebottom"><img src="img/arrow2.gif" />
<a href="./index.php?do=article&id=<?=$row3['4']?>"><?=$row3['5']?></a></td><?
if(($counter2 % $cells_per_row2) == 0){echo "<td width=6%> </td>";}
if(($counter2 % $cells_per_row2) == 1) { echo '</tr>'; }
}
if(($counter2 % $cells_per_row2) ==1) { echo '</tr><tr><td colspan=3><hr></td></tr>'; }
,