balkan7 Posted January 9, 2007 Share Posted January 9, 2007 hi i set limit 4 in my litle shopping and just show me 1 not 4, where i wrong whit this ?index.php[code]<?include_once("conn.php");include_once("lang/english.php");include_once("includes.php");include_once("templates/HeaderTemplate.php");$q1 = "select * from bsoft_catalog, bsoft_categories, bsoft_cd WHERE ItemID = ItemID and ItemCategory = CategoryID and ItemCd = CdID ORDER BY ItemID ASC LIMIT 4";$r1 = mysql_query($q1) or die(mysql_error());if(mysql_num_rows($r1) > '0'){ $a1 = mysql_fetch_array($r1); if(empty($a1[ItemImage])) { $ItemImage = "<img src=\"no_image.gif\" width=\"145\" alt=\"No Image!\" border=0>"; } else { $size = getimagesize("items_images/$a1[ItemImage]"); if($size[0] > 90) { $width = 90; $height = 85; } else { $width = $size[0]; $height = $size[0]; } $ItemImage = "<img src=\"items_images/$a1[ItemImage]\" width=\"$width\" height=\"$height\" alt=\"$a1[ItemName]\" border=0>"; } include_once("templates/IndexTemplate.php");}include_once("templates/FooterTemplate.php");?>[/code]templates/IndexTemplate.php[code]<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><table width=570 valign=top><tr> <td style="background-image: url('images/center.gif')"><?=$lang_katalog_1?></td></tr><tr> <td style="padding-left:10"><?=nl2br($aset[naslovna]);?></td></table><table width=570 valign=top><tr> <td style="background-image: url('images/center.gif')"><?=$lang_katalog_2?></td></tr></table><br><div align="center"> <table border="0" width="445" cellspacing="0" cellpadding="0"> <tr> <td class="ItemTitle" bgcolor="#B2BCBE" width="400"> <p align="center"><?=$a1[ItemName]?></td> <td bgcolor="#B2BCBE" width="50"> <p align="center"><? if ($a1[Novo] == 1) { echo "<img src=\"images/novo.gif\" />"; } ?></td> </tr> </table></div><table align=center width=450 border=0><tr> <td width="110" align=right border=0><?=$ItemImage?></td> <td width="340" valign=top> <table border="0" width="100%" valign=top><tr> <td class=CategoryName bgcolor=#B2BCBE> <font color="#006699"><?=$lang_index_1?> </font><a class=CategoryName href="search.php?CategoryID=<?=$a1[ItemCategory]?>"><?=$a1[CategoryName]?></a> </td></tr><tr> <td class=CdName bgcolor=#B2BCBE> <font color="#006699"><?=$lang_index_2?> </font><?=$a1[CdName]?></td></tr><tr> <td class=ItemDesc colspan=2 bgcolor=#B2BCBE><font color="#006699"><?=$lang_index_3?> </font><?=nl2br($a1[ItemDesc]);?></td></tr><tr> <td class=PriceClass bgcolor=#B2BCBE> <font color="#006699"><?=$lang_index_4?> </font><?=$aset[currency_sign]?> <?=$a1[ItemPrice]?></td></tr><tr> <td></td></tr><tr> <td bgcolor="#B2BCBE"> <div align=center> <a href="view_cart.php"><img src="images/pregled.gif" width="118" height=22 alt="<?=$lang_index_5?>" border=0></a> <a href="add.php?ItemID=<?=$a1[ItemID]?>"><img src="images/dodaj.gif" width="118" height=22 alt="<?=$lang_index_6?>" border=0></a></div></td></tr></td></table></table>[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted January 10, 2007 Share Posted January 10, 2007 If a query only returns 1 record then adding LIMIT 4 isn't going to make if return more.Remove the "LIMIT 4" bit and try again to see how many it returns. Quote Link to comment Share on other sites More sharing options...
weknowtheworld Posted January 10, 2007 Share Posted January 10, 2007 Try to have this query :$q1 = "select * from bsoft_catalog, bsoft_categories, bsoft_cd WHERE ItemID = ItemID and ItemCategory = CategoryID and ItemCd = CdID ORDER BY ItemID ASC LIMIT 0,4";$r1 = mysql_query($q1) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
balkan7 Posted January 10, 2007 Author Share Posted January 10, 2007 i have been removed limit 4, and again show 1 record :-[and i Try to have this query :$q1 = "select * from bsoft_catalog, bsoft_categories, bsoft_cd WHERE ItemID = ItemID and ItemCategory = CategoryID and ItemCd = CdID ORDER BY ItemID ASC LIMIT 0,4";$r1 = mysql_query($q1) or die(mysql_error());nothing again i have just 1 record, in my datebase i have more of 20 records ... Quote Link to comment Share on other sites More sharing options...
Barand Posted January 10, 2007 Share Posted January 10, 2007 In that case there is only one of those records that meets all the conditions specified in your WHERE clause Quote Link to comment Share on other sites More sharing options...
balkan7 Posted January 10, 2007 Author Share Posted January 10, 2007 i dont know how to reslove this case, what must to do to show me more ?or need to paste sql ? Quote Link to comment Share on other sites More sharing options...
fenway Posted January 10, 2007 Share Posted January 10, 2007 Run a COUNT() of the same query and see what you get. Quote Link to comment Share on other sites More sharing options...
balkan7 Posted January 10, 2007 Author Share Posted January 10, 2007 i do not get nothing whit count(*)but i have 3 category and i have count from category and i get number, but where is my mastake whit this :-\ Quote Link to comment Share on other sites More sharing options...
fenway Posted January 10, 2007 Share Posted January 10, 2007 How can it be nothing? You just said you got 1 record. Quote Link to comment Share on other sites More sharing options...
balkan7 Posted January 10, 2007 Author Share Posted January 10, 2007 because i get from 3 tables,i have been change something but no result:[code]$q1 = "select * from bsoft_catalog, bsoft_categories, bsoft_cd WHERE ItemID = ItemID ORDER BY ItemID ASC LIMIT 4";$r1 = mysql_query($q1) or die(mysql_error());[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted January 11, 2007 Share Posted January 11, 2007 You have only about 20 records so why don't you post a structure and record dump of the 3 tables so we can see what you are processing. Quote Link to comment Share on other sites More sharing options...
btherl Posted January 11, 2007 Share Posted January 11, 2007 table1:Id | Name1 | Balkan2 | Btherltable2:Id | Posts1 | 5SELECT * FROM table1, table2 WHERE table1.id = table2.idId | Name | Posts1 | Balkan | 5Notice that "Btherl" is NOT in the results, because it is in only 1 table, not 2 tables. This may be why you are not seeing the results you want. Quote Link to comment Share on other sites More sharing options...
fenway Posted January 11, 2007 Share Posted January 11, 2007 You'd need a LEFT JOIN if you want them all back no mater what. 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.