SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot samohtwerdna's Avatar
    Join Date
    Jul 2007
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    print table help (4 columns 2 record sets)

    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 Code:
    <?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.
    Last edited by samohtwerdna; Jul 31, 2007 at 08:38. Reason: problem in code

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Uhm, not sure what are you doing there with that condition? From what you described, it's just a straightforward display of record set?

    As far as the second table, why not just join the tables and display the data in one table, having the package id's on rightmost column.
    Saul

  3. #3
    SitePoint Zealot samohtwerdna's Avatar
    Join Date
    Jul 2007
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry about the pervious condition mess.

    I have to many package types to display them all at once. Each package has 4 price fields and one record for a retailer and another for a whole seller.

    So what I have done is nested 3 tables inside 1 display table. the last table doesn't have to be a table really - I just want a display that shows the current package type and a << button and a >> button to navigate to other package types


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •