bscotyb Posted April 29, 2012 Share Posted April 29, 2012 i can not get this to show the numbers when i run my php. i know i am missing something simple, it is probably one of my variables, can someone please help me with this for my class, ty html <html> <head> <title>Software2</title> <link rel ="stylesheet" type="text/css" href="sample.css" /> </head> <body> <h1>SOFTWARE ORDERS: REPORT</h1> <form action = "software2Boles.php" method = "post" > <p><input type = "submit" value = "Display the Report" /></p> </form> </body> </html> txt. 1 Linux:1 2 Macintosh:1 3 Windows:1 4 Macintosh:1 5 Macintosh:2 6 Linux:5 7 Macintosh:10 8 Windows:10 9 Macintosh:1 10 Windows:1 11 Windows:1 12 Linux:1 13 Macintosh:5 14 Linux:4 15 Windows:1 16 Macintosh:1 17 Windows:1 18 Linux:2 19 Macintosh:2 20 Windows:1 21 <!--Author: Larry Boles Date: April 21, 2012 File: software2.php Purpose:Chapter 10 Lab --> <html> <head> <title>Software2</title> <link rel ="stylesheet" type="text/css" href="sample.css" /> </head> <body> <?php $multipleOrders = 0; $linuxCopies = 0; $macintoshCopies = 0; $windowsCopies = 0; $orderFile = fopen("ordersBoles.txt", "r"); $nextOrder = fgets ($orderFile); while (!feof($orderFile)) { list($os,$copies) = split (":", $nextOrder); { if ($os == "Linux") { $linuxCopies = $copies + 1; } if ($os == "Macintosh") { $macintoshCopies = $copies +1;} if ($os == "Windows" ) { $windowsCopies = $copies + 1; } if ($os == "Multiple") { $multipleCopies = $copies + 1; } } } $nextOrder = fgets ($orderFile); } fclose($orderFile); print ("<h1>SOFTWARE ORDERS: REPORT</h1>"); print ("<p>ORDERS FOR MULTIPLE COPIES: $multipleOrders</p>"); print ("<p>LINUX COPIES ORDERED: $linuxCopies</p>"); print ("<p>MACINTOSH COPIES ORDERED: $macintoshCopies</p>"); print ("<p>WINDOWS COPIES ORDERED: $windowsCopies</p>"); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/261810-eof-help/ Share on other sites More sharing options...
gizmola Posted April 29, 2012 Share Posted April 29, 2012 The php code you have pasted is not valid. You have a start block and a broken loop that is in the wrong place, so it's no wonder that you're not getting results. In order to get people to help you, you really need to try and ask better questions, and provide more information about what is wrong. I did nothing here other than correct your screwed up blocks and formatting. It's important to indent your blocks so that it's clear to anyone looking at your code how the flow of control works. $multipleOrders = 0; $linuxCopies = 0; $macintoshCopies = 0; $windowsCopies = 0; $orderFile = fopen("ordersBoles.txt", "r"); $nextOrder = fgets ($orderFile); while (!feof($orderFile)) { list($os,$copies) = split (":", $nextOrder); if ($os == "Linux") { $linuxCopies = $copies + 1; } if ($os == "Macintosh") { $macintoshCopies = $copies +1; } if ($os == "Windows" ) { $windowsCopies = $copies + 1; } if ($os == "Multiple") { $multipleCopies = $copies + 1; } $nextOrder = fgets ($orderFile); } fclose($orderFile); print ("SOFTWARE ORDERS: REPORT"); print (" ORDERS FOR MULTIPLE COPIES: $multipleOrders"); print (" LINUX COPIES ORDERED: $linuxCopies"); print (" MACINTOSH COPIES ORDERED: $macintoshCopies"); print (" WINDOWS COPIES ORDERED: $windowsCopies"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/261810-eof-help/#findComment-1341577 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.