samoht Posted July 31, 2007 Share Posted July 31, 2007 Hello Again, I am trying to print a table of prices. I am storing a retail price and a wholesale price in a table productpackaging which is structured like: pdpackId ProductId as int PackageId as int Pcode as varchar RetailPrice as Decimal SellPrice as Decimal HoldPrice as Decimal etc The Pcode field tells me "RT" for retailer or "WS" for wholesale pricing. I want to query this table and print an html table with 4 columns the first for the retail labels - the 2nd for the retail prices - the 3rd for the wholesale labels and the 4th for the wholesale prices <?php $ProductId = $row_rsProducts[ProductId]; $packId = 27; $sql = "SELECT RetailPrice, SellPrice, HoldPrice, Cost, Pcode FROM productpackaging WHERE ProductId = $ProductId AND PackageId = $packId"; $result = mysql_query($sql); $i = 0; print '<table class="prices" width="100%">'; while(($row = mysql_fetch_assoc($result)) !== false) { if($row[Pcode]=="RT") { $i++; print "<tr class=\"d".($i & 1)."\">"; print "<td>Retail</td>"; print "<td>$".$row[RetailPrice]."</td>"; } else{ print "<td>Retail</td>"; print "<td>$".$row[RetailPrice]."</td>"; print "</tr>\n"; } This is what I thought would work - but I am not sure its the best plan of attack. Any Ideas?? Also I want to put another table next to this one that scrolls through PackageId's and allows the user to change the view. Quote Link to comment https://forums.phpfreaks.com/topic/62686-print-table-help-4-columns-2-record-sets/ Share on other sites More sharing options...
eric1235711 Posted July 31, 2007 Share Posted July 31, 2007 that code does this: if P code is RT do: print "<tr class=\"d".($i & 1)."\">"; print "<td>Retail</td>"; print "<td>$".$row[RetailPrice]."</td>"; if P code is anything but RT do: print "<td>Retail</td>"; print "<td>$".$row[RetailPrice]."</td>"; print "</tr>\n"; you are putting inside the condition codes that should be outside. Quote Link to comment https://forums.phpfreaks.com/topic/62686-print-table-help-4-columns-2-record-sets/#findComment-312013 Share on other sites More sharing options...
eric1235711 Posted July 31, 2007 Share Posted July 31, 2007 try something is this way: start loop print open tr print retail message in td if Pcode is RT {print retailprice in td} else {print empty td} print wholesale mesage in td if Pcode is WS {print wholesale in td} else {print empty td} print close tr end loop Quote Link to comment https://forums.phpfreaks.com/topic/62686-print-table-help-4-columns-2-record-sets/#findComment-312016 Share on other sites More sharing options...
DeepakJ Posted July 31, 2007 Share Posted July 31, 2007 oops wrong thread Quote Link to comment https://forums.phpfreaks.com/topic/62686-print-table-help-4-columns-2-record-sets/#findComment-312022 Share on other sites More sharing options...
samoht Posted July 31, 2007 Author Share Posted July 31, 2007 ok I now have a similar stucture to your sugestion. Now I want to have a 3rd table or div, what ever next to these two tables that displays my packaging something like click to see more >> package1 on click the record sets update Currently I have: <?php $packId = 27; $sql = "SELECT RetailPrice, SellPrice, HoldPrice, Cost, Pcode FROM productpackaging WHERE ProductId = $ProductId AND PackageId = $packId"; as a default Any Ideas?? Quote Link to comment https://forums.phpfreaks.com/topic/62686-print-table-help-4-columns-2-record-sets/#findComment-312039 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.