Jump to content

Recommended Posts

 

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.

Link to comment
https://forums.phpfreaks.com/topic/62686-print-table-help-4-columns-2-record-sets/
Share on other sites

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.

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

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??

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.