Skip to content
Snippets Groups Projects
Commit eb134319 authored by Brandon Rodriguez's avatar Brandon Rodriguez
Browse files

Add final requirements for ch10pr03

Needs markup validation?
parent 07fa2cb1
Branches
No related merge requests found
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
if ($_SERVER['REQUEST_METHOD'] == 'GET') { if ($_SERVER['REQUEST_METHOD'] == 'GET') {
if ( isset($_GET['customer']) ) { if ( isset($_GET['customer']) ) {
$requestedCustomer = $customers[$_GET['customer'] - 2]; # -2 because bug somewhere that was returning wrong customer from array, despite GET info in url giving the correct customer number. Don't have time to debug. $requestedCustomer = $customers[($_GET['customer'] - 2)]; # -2 because bug somewhere that was returning wrong customer from array, despite GET info in url giving the correct customer number. Don't have time to debug.
$orders = ReadOrders($requestedCustomer, 'orders.txt'); $orders = ReadOrders($requestedCustomer, 'orders.txt');
if ( is_null($orders) ) { if ( is_null($orders) ) {
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
</tr> </tr>
<?php <?php
CreateOrderRows($requestedCustomer[0], $orders); CreateOrderRows($orders);
?> ?>
</table> </table>
</div> </div>
......
...@@ -13,137 +13,37 @@ ...@@ -13,137 +13,37 @@
$tempOrders = explode("\n", file_get_contents($fileName)); $tempOrders = explode("\n", file_get_contents($fileName));
$tempArrayLength = count($tempOrders); $tempArrayLength = count($tempOrders);
echo "<table>";
echo "<tr>";
echo "<th>CustId</th>";
echo "<th>FName</th>";
echo "<th>LName</th>";
echo "<th></th>";
echo "<th></th>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo $customer[0];
echo "</td><td>";
echo $customer[1];
echo "</td><td>";
echo $customer[2];
echo "</td><td>";
echo $customer[3];
echo "</td><td>";
echo $customer[4];
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<div></div>";
echo "<div></div>";
echo "<div></div>";
$ordersIndex = 0; $ordersIndex = 0;
$orders;
for ($index = 0; $index < ($tempArrayLength - 1); $index++) { for ($index = 0; $index < ($tempArrayLength - 1); $index++) {
$tempOrder = explode(",", $tempOrders[$index]); $tempOrder = explode(",", $tempOrders[$index]);
/*echo "<table>";
echo "<tr>";
echo "<th>OrderId</th>";
echo "<th>CustId</th>";
echo "<th>ISBN</th>";
echo "<th></th>";
echo "<th></th>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo $tempOrder[0];
echo "</td><td>";
echo $tempOrder[1];
echo "</td><td>";
echo $tempOrder[2];
echo "</td><td>";
echo $tempOrder[3];
echo "</td><td>";
echo $tempOrder[4];
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<table>";
echo "<tr>";
echo "<th>CustId</th>";
echo "<th>FName</th>";
echo "<th>LName</th>";
echo "<th></th>";
echo "<th></th>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo $customer[0];
echo "</td><td>";
echo $customer[1];
echo "</td><td>";
echo $customer[2];
echo "</td><td>";
echo $customer[3];
echo "</td><td>";
echo $customer[4];
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<div></div>";*/
/*echo " \n TempOrder: ";
echo $tempOrder[1];
echo "\n";
echo "Customer: ";
echo $customer[0];*/
if ($tempOrder[1] == $customer[0]) { if ($tempOrder[1] == $customer[0]) {
$orders[$ordersIndex] = $tempOrder; $orders[$ordersIndex] = $tempOrder;
echo $orders[$ordersIndex][0];
echo " - ";
echo $orders[$ordersIndex][1];
echo " - ";
echo $orders[$ordersIndex][2];
echo " - ";
echo $orders[$ordersIndex][3];
$ordersIndex++; $ordersIndex++;
} }
} }
echo "<div>"; if (isset($orders)) {
echo $orders[0][1]; return $orders;
echo " - "; } else {
echo $orders[0][2];
echo "</div>"; }
echo "<p> Orders is valid and has values when customer has orders, so why does it seem to always display 'no orders for customer'? DEBUG LATER IF TIME </p>";
} }
function CreateOrderRows($customerId, $orders) { function CreateOrderRows($orders) {
#$ordersPresent = 0; #$ordersPresent = 0;
#if ($orders[$index][1] == $customerId) { $ordersArrayLength = count($orders);
for ($index = 0; $index < ($ordersArrayLength); $index++) {
echo "<tr>"; echo "<tr>";
echo "<td><img src='images/book/tinysquare/"; echo "<td><img src='images/book/tinysquare/" . $orders[$index][2] . ".jpg'></td>";
echo $orders[$index][2]; echo "<td><a href='chapter10-project03.php?isbn=" . $orders[$index][2] . "'>" . $orders[$index][2] . "</td>";
echo ".jpg'></td>"; echo "<td>" . $orders[$index][3] . "</td>";
echo "<td><a href='chapter10-project03.php?isbn="; echo "<td>" . $orders[$index][4] . "</td>";
echo $orders[$index][2];
echo "</td>";
echo "<td>";
echo $orders[$index][3];
echo "</td>";
echo "<td>";
echo $orders[$index][4];
echo "</td>";
echo "</tr>"; echo "</tr>";
}
#$ordersPresent = 1;
#}
#if ($ordersPresent == 0) {
# echo "No Orders Present.";
#}
} }
?> ?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment