motherboards
Arctic
Results 1 to 4 of 4

Thread: PHP array help

  1. #1
    Member

    Status
    JKershner is offline

    Last Online
    13-10-2014 @ 12:47
    Join Date
    Jul 2013
    Location
    Boise, ID
    Posts
    75
    CPU: AMD FX-9370 @ 5Ghz
    M/B: Gigabyte GA-990FXA-UD7
    RAM: Kingston HyperX 8GB 2133Mhz
    GPU: 3x Sapphire 100363L R9 280X
    • JKershner's Full Spec's
      • Case:
      • PrimoChill Wet Bench
      • PSU:
      • NZXT Hale90V2 1000w
      • Cooling:
      • Cryorig R1 Ultimate
      • Monitor:
      • 3x BenQ 24"
      • OS:
      • Win7 Ult. 64bit
    Thanks
    33
    Thanked 8 Times in 6 Posts
    Points: 1,987, Level: 12
    Points: 1,987, Level: 12
    Level completed: 46%,
    Points required for next Level: 163
    Level completed: 46%, Points required for next Level: 163
    Overall activity: 0%
    Overall activity: 0%

    Default PHP array help

    Hello everybody, I'm having a slight problem adding an array. I have multiple items being pulled from the database which as the quantity*price=total, I'm getting that but I need to add the total to get the final total for an invoice.

    Here's the code I'm using:
    Code:
    while($row=mysql_fetch_array($result2)) {			$a=$row['price_revision'];
    			$b=$row['quantity'];
    			$total= ($a*$b);
    			?>
    			<tr><td><?php echo $row['part_number'];?></td>
    			<td><?php echo $row['description'];?></td>
    			<td><?php echo $row['material'];?></td>
    			<td><?php echo $row['drawing_no'];?></td>
    			<td><?php echo $row['price_revision'];?></td>
    			<td><?php echo $row['quantity'];?></td>
    			<td><?php echo "$ ", $total;?></td></tr><?php ;}?></td></tr>
    			<tr><th><th><th><th><th><th>Total</th><td style=text-align:center;><?php echo "$". $total ;?>
    Here's the results I'm getting. I'm sure I'm missing a step but the final total needs to equal the item totals.


  2. #2
    Regular Member

    Status
    Shell_Shock is offline

    Last Online
    05-07-2016 @ 00:39
    Join Date
    Aug 2013
    Location
    Waterford, PA
    Posts
    235
    CPU: Intel G3259 3.2 GHZ LGA 1150
    M/B: MSI Z97 PC Mate
    RAM: Kingston 125GB SSD
    GPU: PNY 465
    • Shell_Shock's Full Spec's
      • Case:
      • ThermalTake Urban T81
      • PSU:
      • EnerMax Revolution Xt 630w
      • Cooling:
      • Dragons blood dye, NZXT 240mm RAD, Danger Den Bay Res, DDC Pump, Primochill Fittings, PETG HArd Line Tubing
      • Monitor:
      • Piece of Crap
      • OS:
      • Windows 8.1
    Thanks
    1
    Thanked 24 Times in 18 Posts
    Points: 3,693, Level: 17
    Points: 3,693, Level: 17
    Level completed: 61%,
    Points required for next Level: 157
    Level completed: 61%, Points required for next Level: 157
    Overall activity: 13.0%
    Overall activity: 13.0%

    Default Re: PHP array help

    I'll be honest, i have no skill, knowledge or experience with PHP. But to me it seems like in your program you're missing a step in the line:
    PHP Code:
    <tr><th><th><th><th><th><th>Total</th><td  style=text-align:center;><?php echo "$"$total ;?>
    Programmer, Ethical Hacker, Tech Support, Geek Extraordinaire.

  3. #3
    Core Member

    Status
    killjoyjim is offline

    Last Online
    24-08-2018 @ 17:02
    Join Date
    Dec 2011
    Location
    corry pa
    Posts
    4,837
    CPU: INTEL i5 4670k
    M/B: ASUS MAXIMUS VII HERO
    RAM: CORSAIR DOMINATOR PLATINUM 16GB 2133
    GPU: Two GIGABYTE 670. With EXPC waterblocks and back plats.
    • killjoyjim's Full Spec's
      • Case:
      • Case Labs Magnum TH 10. With custom paint.
      • PSU:
      • AZZA TITAN 1000w
      • Cooling:
      • D5 pump with dress up kit and block. Custom Res with three XSPC 480mm rads. Swifteck CPU block and Two XSPC water blocks on my 670 cards.
      • Sound:
      • ASUS ROG THUNDERBOLT
      • Monitor:
      • 47'' samsung tv
      • OS:
      • windows 7
      • Misc:
      • OCZ 60gb fot OS. And a OCZ 240 ssd.
    Thanks
    30
    Thanked 416 Times in 378 Posts
    Points: 75,825, Level: 85
    Points: 75,825, Level: 85
    Level completed: 58%,
    Points required for next Level: 725
    Level completed: 58%, Points required for next Level: 725
    Overall activity: 0%
    Overall activity: 0%

    Default Re: PHP array help

    Quote Originally Posted by Shell_Shock View Post
    I'll be honest, i have no skill, knowledge or experience with PHP. But to me it seems like in your program you're missing a step in the line:
    PHP Code:
    <tr><th><th><th><th><th><th>Total</th><td  style=text-align:center;><?php echo "$"$total ;?>

  4. #4
    New Member

    Status
    SimpleCookie is offline

    Last Online
    03-01-2015 @ 17:09
    Join Date
    Jan 2015
    Location
    Sweden
    Posts
    2
    CPU: Intel i5 2500k
    M/B: MSI P67A-GD65 REV B3
    RAM: 8 GB 1600 MHz
    GPU: GTX 570
    • SimpleCookie's Full Spec's
      • Case:
      • Fractal Design R3
      • PSU:
      • BeQuiet 700W
      • Cooling:
      • Corsair h60 liquid
      • Sound:
      • None
      • Monitor:
      • 17&quot; acer
      • OS:
      • Windows 8.1 and Ubuntu Linux
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Points: 134, Level: 1
    Points: 134, Level: 1
    Level completed: 84%,
    Points required for next Level: 16
    Level completed: 84%, Points required for next Level: 16
    Overall activity: 3.0%
    Overall activity: 3.0%

    Default Re: PHP array help

    Now this is another old thread I'm replying to, anyway, I haven't tested it but I got annoyed at all those php declarations you got for no good reason so changed it..

    Code:
    <?php     while($row=mysql_fetch_array($result2)) {            
            $a=$row['price_revision'];
            $b=$row['quantity'];
            $total= ($a*$b);
            
            echo "<tr><td>".$row['part_number']."</td>
                <td>".$row['description']."</td>
                <td>".$row['material']."</td>
                <td>".$row['drawing_no']."</td>
                <td>".$row['price_revision']."</td>
                <td>".$row['quantity']."</td>
                <td>$ , ".$total."</td></tr>"; 
        }
    ?>
    </td></tr>
    <tr><th><th><th><th><th><th>Total</th><td style=text-align:center;><?php echo "$". $total ;?>
    Regarding your problem..
    I don't quite get what your problem is, but could it be that simple that you're wanting to do this ..
    $total += ($a*$b);
    Basically doing $total = ($a*$b)+$total ?

Remove Ads

Sponsored Links

Posting Permissions

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

Similar Threads

  1. Replies: 0
    Last Post: 03-06-2014, 13:30
  2. Addonics New Snap-In Disk Array Solutions
    By News Team in forum Hardware News
    Replies: 0
    Last Post: 19-09-2011, 18:30
  3. ASUS Unveils an Array of Brand New Display Products
    By News Team in forum Hardware News
    Replies: 0
    Last Post: 26-05-2010, 22:03
  4. NVIDIA raid disk 20 SCSI array drivers
    By bloodyrose in forum General Software
    Replies: 0
    Last Post: 22-05-2010, 10:06

Search tags for this page

There are currently no search tags.
Click on a term to search for related topics.

Tags for this Thread