Re: problem formatting output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi David,

This is what the generated html looks like. It's a lot sorry about all the
output:

<html>
<head>
<title>Bob’s Auto Parts - Customer Orders</title>
</head>
<body>
<h1>Bob’s Auto Parts</h1>
<h2>Customer Orders</h2>
<table border="1">
<tr><th bgcolor="#CCCCFF">Order Date</th>
     <th bgcolor="#CCCCFF">Tires</th>
     <th bgcolor="#CCCCFF">Oil</th>
     <th bgcolor="#CCCCFF">Spark Plugs</th>
     <th bgcolor="#CCCCFF">Total</th>
     <th bgcolor="#CCCCFF">Address</th>
     <tr><tr>
       <td>9:49pm EST  Saturday,  01/03/2015</td>
       <td align="right">1</td>
       <td align="right">2</td>
       <td align="right">5</td>
       <td align="right">$140.00</td>
       <td>
</td>
       </tr><tr>
       <td>960 Fairview Dr</td>
       <td align="right">0</td>
       <td align="right">8753</td>
       <td align="right">0</td>
       <td align="right">
</td>
       <td></td>
       </tr><tr>
       <td>10:05pm EST  Saturday,  01/03/2015</td>
       <td align="right">1</td>
       <td align="right">2</td>
       <td align="right">5</td>
       <td align="right">$140.00</td>
       <td>
</td>
       </tr><tr>
       <td>904 Sylvan Ave</td>
       <td align="right">0</td>
       <td align="right">7632</td>
       <td align="right">0</td>
       <td align="right">
</td>
       <td></td>
       </tr><tr>
       <td>10:06pm EST  Saturday,  01/03/2015</td>
       <td align="right">3</td>
       <td align="right">3</td>
       <td align="right">4</td>
       <td align="right">$346.00</td>
       <td>
</td>
       </tr><tr>
       <td>900 Sylvan Ave</td>
       <td align="right">0</td>
       <td align="right">7632</td>
       <td align="right">0</td>
       <td align="right">
</td>
       <td></td>
       </tr><tr>
       <td>10:07pm EST  Saturday,  01/03/2015</td>
       <td align="right">1</td>
       <td align="right">2</td>
       <td align="right">5</td>
       <td align="right">$140.00</td>
       <td>
</td>
       </tr><tr>
       <td>960 Fairview Dr</td>
       <td align="right">0</td>
       <td align="right">8753</td>
       <td align="right">0</td>
       <td align="right">
</td>
       <td></td>
       </tr></table></body>
</html>

I notice that this is the first entry that looks screwed up:

</td>
       </tr><tr>
       <td>960 Fairview Dr</td>
       <td align="right">0</td>
       <td align="right">8753</td>
       <td align="right">0</td>
       <td align="right">
</td>

Also I opened up the web server so that you can see the original web pages.
Here's the link to this page:

http://php.lyricgem.com/code/vieworders3.php

Here's another page with less formating that shows you the contents of that
file:

http://php.lyricgem.com/code/vieworders.php

At least here all the information in the output makes some sense. Still not
sure from looking at the generated html where the problem lies
unfortunately.

Thanks
Tim

On Sat, Jan 3, 2015 at 10:46 PM, David OBrien <dgobrien@xxxxxxxxx> wrote:

>
>
> On Sat, Jan 3, 2015 at 10:31 PM, Tim Dunphy <bluethundr@xxxxxxxxx> wrote:
>
>> Hey all,
>>
>>  Followign along in php & mysql web development by Luke Welling and Laura
>> Thompson I came along an example to format the output text file. The file
>> was meant to hold the orders of a fctional online store.
>>
>> Here's the output of the code:
>>
>> Bob’s Auto PartsCustomer OrdersOrder DateTiresOilSpark
>> PlugsTotalAddress9:49pm
>> EST Saturday, 01/03/2015125$140.00960 Fairview Dr08753010:05pm EST
>> Saturday, 01/03/2015125$140.00904 Sylvan Ave07632010:06pm EST Saturday,
>> 01/03/2015334$346.00900 Sylvan Ave07632010:07pm EST Saturday,
>> 01/03/2015125
>> $140.00960 Fairview Dr087530
>>
>> As you can see, at the first line the address entry doesn't line up and
>> then throws the rest of the form out of whack.
>>
>> Here's the code that I tried:
>>
>> <?php
>> //create short variable name
>> $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
>> ?>
>> <html>
>> <head>
>> <title>Bob’s Auto Parts - Customer Orders</title>
>> </head>
>> <body>
>> <h1>Bob’s Auto Parts</h1>
>> <h2>Customer Orders</h2>
>> <?php
>> //Read in the entire file.
>> // Each order becomes an element in the array
>> $orders= file("$DOCUMENT_ROOT/../orders/orders.txt");
>> // count the number of orders in the array
>> $number_of_orders = count($orders);
>> if ($number_of_orders == 0) {
>>     echo "<p><strong>No orders pending. Please try again
>> later.</strong></p>";
>> }
>> echo "<table border=\"1\">\n";
>> echo "<tr><th bgcolor=\"#CCCCFF\">Order Date</th>
>>      <th bgcolor=\"#CCCCFF\">Tires</th>
>>      <th bgcolor=\"#CCCCFF\">Oil</th>
>>      <th bgcolor=\"#CCCCFF\">Spark Plugs</th>
>>      <th bgcolor=\"#CCCCFF\">Total</th>
>>      <th bgcolor=\"#CCCCFF\">Address</th>
>>      <tr>";
>> for ($i=0; $i<$number_of_orders; $i++) {
>> //split up each line
>> $line = explode("\t", $orders[$i]);
>> // keep only the number of items ordered
>> $line[1] = intval($line[1]);
>> $line[2] = intval($line[2]);
>> $line[3] = intval($line[3]);
>>
>>     /*
>> for ($x = 0; $x <= count($line); $x++) {
>>     var_dump($line[$x]);
>>     echo "<br />";
>> }
>>     */
>>
>> // output each order
>> echo "<tr>
>>        <td>".$line[0]."</td>
>>        <td align=\"right\">".$line[1]."</td>
>>        <td align=\"right\">".$line[2]."</td>
>>        <td align=\"right\">".$line[3]."</td>
>>        <td align=\"right\">".$line[4]."</td>
>>        <td>".$line[5]."</td>
>>        </tr>";
>> }
>> echo "</table>";
>>
>> ?>
>> </body>
>> </html>
>>
>> I've tried staring at the code for a while, but unfortunately I can't seem
>> to wrap my head around why this is outputting incorrectly. I was hoping
>> some more experienced hands could have a look and let me know where I'm
>> going wrong in this example.
>>
>> Certainly thanks for your help! This list is really a benefit to my
>> ongoing
>> education with PHP!  And I definitely appreciate the help!
>>
>> Tim
>>
>> --
>> GPG me!!
>>
>> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
>>
>
>
> What's the generated html source code look like?
>
>
>


-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux