Jump to content

EOF help


bscotyb

Recommended Posts

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>

Link to comment
Share on other sites

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");
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.