Jump to content

bscotyb

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Posts posted by bscotyb

  1. 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>
    

  2. i am a student and trying to figure out why this is not working for me i am trying to pull from my .txt file and add the lines.  $numOrders should be 20 and $numCopies should be 52.  it keeps telling me --Warning: feof() expects parameter 1 to be resource, string given on line 25.  i really am having big trouble trying to understand how to use the while loop for this.  any help would be great.

     

    here is my html code

    <html>

    <head>

    <title>Software1</title>

    <link rel ="stylesheet" type="text/css" href="sample.css" />

    </head>

    <body>

    <h1>SOFTWARE ORDERS: REPORT</h1>

    <form action = "software1Boles.php" method = "post" >

    <p><input type = "submit" value = "Display the Report" /></p>

    </form>

    </body>

    </html>

     

    my php code

    <?php

    $totalCopies = $_POST['totalCopies'];

    $totalOrders = $_POST['totalOrders'];

    $nextOrder = $_POST['nextOrder'];

     

     

    $totalCopies = 0;

    $totalOrders = 0;

     

    $orderFile = fopen("ordersBoles.txt", "r");

    $nextOrder = fgets ($orderFile);

    while (!feof($nextOrder))

    {

    list($totalCopies, $totalOrders) = explode (":", $nextOrder);

     

    if ($totalCopies >=1 and $totalCopies >=1)

    {

    $totalCopies = $totalCopies + $nextOrder;

    $totalOrder = $totalOrder + $nextOrder;

    }

    $nextOrder = fgets($orderFile);}

    fclose($orderFile);

     

    print ("<h1>SOFTWARE ORDERS: REPORT</h1>");

    print ("<p>TOTAL COPIES ORDERED: $totalCopies</p>");

    print ("<p>TOTAL ORDERS: $totalOrders</p>");

     

    ?>

    </body>

    </html>

     

    and my .txt file

     

     

    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

     

     

    anything you can give me would help alot, thanks

  3. i am trying to pull a .txt file for a class assignment and it is pulling everything except for line 1 any suggestions would be great

     

    html:

     

    <html>

    <head>

    <title>Weekly Report</title>

    <link rel ="stylesheet" type="text/css" href="sample.css" />

    </head>

     

    <body>

    <h1>Weekly Report</h1>

    <p>

    <form action = "weeklyReport1Boles.php" method = "post" >

    <p>

    <input type = "submit" value = "Display the Report" />

    </p>

    </form>

    </body>

    </html>

     

    txt.file

    1  236.00

    2  284.00

    3  148.00

    4  128.00

    5  0.00

    6  110.00

    7  0.00

    8

     

    php file:

     

    <?php

     

    $total = $_POST['total'];

    $avgDailyIncome = $_POST['avgDailyIncome'];

    $badDays = $_POST ['badDays'];

    $paintFile = $_POST ['paintfile'];

    $nextDay = $_POST['nextDay'];

     

    $paintFile = fopen("weeklyDataBoles.txt","r");

    $week = fgets($paintFile);

    $total = 0;

     

    for ($count = 1; $count <=8; $count = $count +1)

    {     

    $nextDay = fgets($paintFile);

    $total = $total + $nextDay;

    }

    $avgDailyIncome = $total/7;

    print("<p>TOTAL INCOME FROM PAINT CONTRACTS: ");

    print("$".number_format($total, 2)."</p>");

    print("<p>AVG DAILY INCOME FROM PAINT CONTRACTS: ");

    print("$".number_format($avgDailyIncome, 2)."</p>");

    print("<p>NUMBER OF DAYS with NO INCOME: $badDays.</p>");

     

    ?>

    </body>

    </html>

  4. i am not asking for much, i am trying and i am really confused all i was really asking for was a little help, i am sorry if my inexperience is a bad thing here, i am trying as hard as i can to understand just having alot of problems getting it

  5. i am a student trying to figure this out and no matter what i do it is not coming up correctly

    I am trying to use this weeklyReport1Boles.html:

    <html><head>

        <title>Weekly Report</title>

    <link rel ="stylesheet" type="text/css" href="sample.css" /></head><body>

        <h1>Weekly Report</h1>

    <p>

          <form action = "weeklyReport1Boles.php" method = "post" >

    <p>

          <input type = "submit" value = "Display the Report" /></p>

    </form>

    </body>

    </html>

     

    TO PULL data from weeklyDataBoles.txt lines 1-8

    1    236.00

    2    284.00

    3    148.00

    4    128.00

    5      0.00

    6    110.00

    7      0.00

    8

     

    the resulting web page should be:

     

    Weekly Report

     

    TOTAL INCOME FROM PAINT CONTRACTS: $0.00

     

    AVG DAILY INCOME FROM PAINT CONTRACTS: $0.00

     

    NUMBER OF DAYS with NO INCOME: .

     

    ny php code is :

     

    <?php

                            $total = $_POST['total'];

                            $avgDailyIncome = $_POST['avgDailyIncome'];

                            $badDays = $_POST ['badDays'];

                            $paintFile = fopen("weeklyDataBoles.txt","r");

                  $year = fgets($weeklyDataBoles);$total = 0;

                  for ($count= 1; $count <=7; $count = $count +1)

              {       $

                  nextDay = fgets($weeklyDataBoles);      

                  $total = $total + $nextDay; }

                  fclose($weeklyData);

                  $avgDailyIncome = $total/7;

     

              print("<p>TOTAL INCOME FROM PAINT CONTRACTS: ");

              print("$".number_format($total, 2)."</p>"); print("<p>AVG DAILY INCOME FROM PAINT CONTRACTS: ");

              print("$".number_format($avgDailyIncome, 2)."</p>");

              print("<p>NUMBER OF DAYS with NO INCOME: $badDays.</p>");

    ?>

    </body>

    </html>

     

    I am very inexperienced and would love any help offered.  Please remember I am a student so my code may be in the shambles already. ty

  6. I am trying to use this weeklyReport1Boles.html:

    <html>
    <head>
    <title>Weekly Report</title>
    <link rel ="stylesheet" type="text/css" href="sample.css" />
    </head>
    
    <body>
    <h1>Weekly Report</h1>
    <p>
    <form action = "weeklyReport1Boles.php" method = "post" >
    	<p>
    	<input type = "submit" value = "Display the Report" />
    	</p>
    </form>
    </body>
    </html>
    

     

    TO PULL data from weeklyDataBoles.txt lines 1-8

    1    236.00

    2    284.00

    3    148.00

    4    128.00

    5      0.00

    6    110.00

    7      0.00

    8

     

    THE RESULTING WEB PAGE SHOULD BE:

     

    Weekly Report

     

    TOTAL INCOME FROM PAINT CONTRACTS: $0.00

     

    AVG DAILY INCOME FROM PAINT CONTRACTS: $0.00

     

    NUMBER OF DAYS with NO INCOME: .

     

    MY PHP CODE IS:

     

    <?php
    $total = $_POST['total'];
    $avgDailyIncome = $_POST['avgDailyIncome'];
    $badDays = $_POST ['badDays'];
    
    $paintFile = fopen("weeklyDataBoles.txt","r");
    $year = fgets($weeklyDataBoles);
    $total = 0;
    for ($count= 1; $count <=7; $count = $count +1)
    {
          $nextDay = fgets($weeklyDataBoles);
          $total = $total + $nextDay;
    }
    fclose($weeklyData);
    $avgDailyIncome = $total/7;
    
    print("<p>TOTAL INCOME FROM PAINT CONTRACTS: ");
    print("$".number_format($total, 2)."</p>");
    print("<p>AVG DAILY INCOME FROM PAINT CONTRACTS: ");
    print("$".number_format($avgDailyIncome, 2)."</p>");
    print("<p>NUMBER OF DAYS with NO INCOME: $badDays.</p>");
    
    ?>
    
    </body>
    </html>
    

     

     

    THE AVERAGES ARE BASED ON ONE WEEK OR SEVEN DAYS, WHY CANT I OPEN THE FILE AND GET THE PROGRAM TO READ IT, I AM A STUDENT AND VERY, VERY, VERY BAD AT THIS, MAKES ME CRAZY CAUSE I REALLY LOVE IT

     

     

     

     

     

  7. that really helped me alot appreciate it, now i have one more question when i input in the html

     

    start with: 10

    End with: 20

    Increment by: 2

     

    in the html it wont square 20 still give me square for 18 what did i do wrong now, :(

     

    <?php

    $startNum = $_POST['startNum'];

    $endNum = $_POST['endNum'];

    $increment = $_POST['increment'];

    $square = $_POST['square'];

     

    print ("<h1>SQUARES</h1><hr />");

     

    for($startNum = $startNum; $startNum < $endNum; $startNum = $startNum += $increment)

    {

    $square = $startNum * $startNum; 

    print("The square of " . $startNum . " is " . $square . "<br/>\n");}

    {    print("The square of " . $startNum . " is " . $square . "<br/>\n");}

    print ("<hr />");

    ?>

  8. i am having issues with my class work.  this needs to start at the $startNum and end with the $endNum and display results in the increments submitted by the html.  I can not get it to print out correctly  it is supposed to say:

    The square of $startNum is $square //until it hits the end number and is going up by the correct increments,

    It wont go up by any increments and only shows a list if i leave out the increment-----any suggestions??? please i have to keep it very simple since i am just learning-ty

     

    html

     

    </head>

    <body>

    <h1>Squares</h1>

    <p>

    <form action = "squares2Boles.php" method = "post" >

    <p>Start with:

    <input type = "text" size = "5" name = "startNum" />

    </p><p>End with:

    <input type = "text" size = "5" name = "endNum" />

    </p><p>Increment by:

    <input type = "text" size = "5" name = "increment" />

    </p><p><input type = "submit" value = "Display the Squares" /></p>

    </form>

    </body>

    </html>

     

    my php:

     

    <html>

    <head>

    <title>Squares</title>

    <link rel ="stylesheet" type="text/css" href="sample.css" />

    </head>

    <body>

    <?php

    $startNum = $_POST['startNum'];

    $endNum = $_POST['endNum'];

    $increment = $_POST['increment'];

    $square = $_POST['square'];

    print ("<h1>SQUARES</h1><hr />");

    for ($startNum = $startNum; $startNum <= $endNum;

    $startNum = $startNum + $increment)

    $square = $startNum * $startNum;

    print ("The square of $startNum is $square<br />");

    }

    print ("<hr />");

    ?>

    </body>

    </html>

  9. <html>

    <head>

    <title>Travel</title>

    <link rel ="stylesheet" type="text/css" href="sample.css" />

    </head>

     

    <body>

    <h1>Travel Reservation Form</h1>

    <p>

    <form action = "travelBoles.php" method = "post" >

     

    <table>

    <tr><td>Select your vacation destination</td>

    <td><select name = "destination" />

    <option>Barcelona</option>

    <option>Cairo</option>

    <option>Rome</option>

                                          <option>Santiago</option>

    <option>Tokyo</option> </select></td></tr>

     

    <tr><td>How many people are traveling?</td>

    <td><input type = "text" size = "5" name = "numTravelers" /></td>

    </tr><tr><td>How many nights will you be staying?</td>

    <td><input type = "text" size = "5" name = "numNights" /></td></tr>

    </table>

    <p><input type = "submit" value = "Submit Your Reservation" /></p>

    </form>

    </body>

    </html>

  10. :wtf:

    i have been trying to make this work for days, this needs to also include a discount for staying over >=5 days in Tokyo, no matter what i do i always gets syntax error this class is making me crazy how do i go about getting the discount in this????? please help

    <?php

    $destination = $_POST['destination'];

    $numTravelers = $_POST['numTravelers'];

    $numNights = $_POST['numNights'];

    $airFare = $_POST['airFare'];

    $hotel = $_POST['hotel'];

     

    if ($destination == Barcelona)

    {$airFare = 875.00;

    $perNight = 85.00;}

    elseif ($destination == Cairo)

    {$airFare= 950.00;

    $perNight = 98.00;}

    elseif ($destination == Rome)

    {$airFare = 875.00;

    $perNight = 110.00;}

    elseif ($destination == Santiago)

    {$airFare = 820.00;

    $perNight = 85.00;}

    elseif ($destination == Tokyo)

    {$airFare = 1575.00;

    $perNight = 240.00;}

    this is where i can not figure out how to put in the discount off the airfare for staying over five days

    elseif ($destination == Tokyo && $numNights >=5)

    $tickets = $numTravelers * $airFare;

    $hotel = $numTravelers * $numNights * $perNight;

    $totalCost = $tickets + $hotel;

     

    print("<p>Destination: $destination<br />");

    print("Number of people: $numTravelers<br />");

    print("Number of nights: $numNights<br />");

    print("Airline Tickets: $".number_format($tickets, 2)."<br />");

    print("Hotel Charges: $".number_format($hotel, 2)."</p>");

    print("<p><strong>TOTAL COST: $".number_format($totalCost, 2)."</strong></p>");

    ?>

×
×
  • 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.