Basically I need to count up the number of orders total (how many people ordered) total copies sold (the number of orders per person).
Below is what I have so far.... and below that is a copy of the .txt file I'm reading from.
But it's not working.
This is one of those simple things that I'm just missing, I know it
Code: Select all
<?php
$totalCopies = 0;
$totalOrders = 0;
$orderFile = fopen("orders.txt", "r");
$nextOrder = fgets ($orderFile);
while (!feof ($orderFile))
{
list ($order, $copies) = split (":", $nextOrder);
$totalOrders = $order + $totalOrders;
$totalCopies = $copies = $totalCopies;
$nextOrder = fgets($orderFile);
}
fclose ($orderFile);
print ("<h1>SOFTWARE ORDERS: REPORT</h1>");
print ("<p>TOTAL COPIES ORDERED: $totalCopies</p>");
print ("<p>TOTAL ORDERS: $totalOrders</p>");
?>Linux:1
Macintosh:1
Windows:1
Macintosh:1
Macintosh:2
Linux:5
Macintosh:10
Windows:10
Macintosh:1
Windows:1
Windows:1
Linux:1
Macintosh:5
Linux:4
Windows:1
Macintosh:1
Windows:1
Linux:2
Macintosh:2
Windows:1
****Eh, nevermind. I got it.