e1seix Posted August 29, 2007 Share Posted August 29, 2007 what am i doing wrong here guys? $startrow=0; $limit=20; $qry = mysql_query("SELECT bodycare.*, haircare.* FROM bodycare, haircare WHERE bodycare.avail='true' AND haircare.avail='true' LIMIT $startrow, $limit")or die(mysql_error()); it should return 6 results between bodycare and haircare. instead it returns 8, - 4 repeats of the first haircare product and 4 of the second haircare product. There are only 2 haircare products in total and 4 bodycare, but the bodycare aren't turning up at all why? can you help me fix it? Quote Link to comment https://forums.phpfreaks.com/topic/67240-solved-result-query-producing-extra-results/ Share on other sites More sharing options...
e1seix Posted August 29, 2007 Author Share Posted August 29, 2007 echo "<td class='mid_col' valign='top'>"; mysql_connect("*.*.*.*", "***_*****", "********") or die(mysql_error()); mysql_select_db("****_**") or die(mysql_error()); $startrow=0; $limit=20; $qry = mysql_query("SELECT bodycare.*, haircare.* FROM bodycare, haircare WHERE bodycare.avail='true' AND haircare.avail='true' LIMIT $startrow, $limit")or die(mysql_error()); echo "<table><tr>"; $i=0; while ($row = mysql_fetch_array($qry)) { if ($i >3) { echo "<tr>"; $i=0; } echo "<td style='font-size:10px;text-align:center;width:125px' valign='top'>"; echo '<a href="'.$_HTTPS['PHP_SELF'].''.$row['page'].'.php?sku='.$row['sku'].'"><img alt="'.$row['title'].'" height="100" src="'.$_HTTPS['PHP_SELF'].'/images/'.$row['ima_link'].'.jpg" width="100" /></a><br />'; echo "<div style='border: 1px solid #000000'><div style='display:block;height:60px'>"; echo '<a href="'.$_HTTPS['PHP_SELF'].''.$row['page'].'.php?sku='.$row['sku'].'" style="color:#000000">'; echo "<span style='font-size:12px;text-align:center'>"; echo $row[title]."</span> / <span style='font-size:12px;text-align:center'>"; echo $row[brand]."</span> <span style='font-size:12px;text-align:center'>"; echo $row['size']. " ". $row['type']."</span></a></div><br />"; echo '<div>'; echo '<a href="'.$_HTTPS['PHP_SELF'].''.$row['page'].'.php?sku='.$row['sku'].'"><img alt="INFO" height="15" src="/INFO.gif" width="50" /></a>'; echo '<a href="'.$row['buy_link'].'" target="_new"><img alt="BUY" height="15" src="/BUY.gif" width="50" /></a></div><br />'; echo '<div style="background-image:url(bg3.JPG);border 1px solid #000000"><span style="color:#ffffff;font-size:12px;font-weight:bold">RRP <span style="color:#ffffff;font-size:12px;font-weight:bold">£<span style="color:#ffffff;font-size:12px;font-weight:bold;text-decoration: line-through">'; echo $row[rrp]."</span><br /><span style='color:#ff9999;font-size:12px;font-weight:bold'>Our Price <span style='color:#ff9999;font-size:16px;font-weight:bold'>"; echo "£".$row[£]."</span><br /><span style='color:#ffffff;font-size:12px;font-weight:bold'>"; $save=($row[rrp]-$row[£]); $saving = number_format($save, 2, '.', ''); $perc=($save/($row[rrp]/100)); $percentage = number_format($perc, 2, '.', ''); echo "Saving <span style='color:#ffffff;font-size:12px;font-weight:bold'>£".$saving." (".$percentage."%)</span></div></div></td>"; $i++; } echo "</td></tr>"; please ignore the fact the coding is far from tidy expecially the main results display bit, but can you guys figure this out at all. i'm really struggling! ??? Quote Link to comment https://forums.phpfreaks.com/topic/67240-solved-result-query-producing-extra-results/#findComment-337295 Share on other sites More sharing options...
sasa Posted August 29, 2007 Share Posted August 29, 2007 try $qry = mysql_query("SELECT * FROM bodycare WHERE bodycare.avail='true' UNION SELECT * FROM haircare WHERE haircare.avail='true' LIMIT $startrow, $limit")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/67240-solved-result-query-producing-extra-results/#findComment-337323 Share on other sites More sharing options...
e1seix Posted August 29, 2007 Author Share Posted August 29, 2007 xxxx SORTED! Quote Link to comment https://forums.phpfreaks.com/topic/67240-solved-result-query-producing-extra-results/#findComment-337333 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.