Re: problem formatting output

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

 



>
> It looks as though your address starts on a new line, so that your number
> of orders is doubled, and every second order is actually the address for
> the order on the preceding line.  Are you assuming that all of the data for
> each order, including the address, is on the same line?


Bingo!!! That was the issue. In my processorder.php script (the action that
the html form points to) I have the following string that I construct to
write to the file:

$outputstring = $date."\t".$tireqty." tires \t".$oilqty." oil\t"
    .$sparkqty." spark plugs\t\$".$totalamount."\t*\n*". $street."\t".
$town."\t". $zip."\t". $state."\t\n";

For some reason, I let a newline sneak into the output string. It was
probably a mistake while I was editing it. Correcting the string like this
solves the issue.

$outputstring = $date."\t".$tireqty." tires \t".$oilqty." oil\t"
    .$sparkqty." spark plugs\t\$".$totalamount."\t". $street."\t".
$town."\t". $zip."\t". $state."\t\n";


Now the output is all on one line. There was an issue with a <tr> tag that
wasn't closed. Thanks also for catching that. But the newline was the main
problem I was having because it was breaking up the output into two lines.
And the script I was using to view the orders was not expecting that.


A text file to hold the orders of a fictional online store? That's not the
> way I would do it.
> My advice, take everything to a MySQL database. Place your Product,
> Customers, and Sales in different tables. That way it will become a simple
> matter to keep track of everything.


Yep!!! Most definitely, Tedd. I'm getting there. This was only to fulfill
the requirements of the lesson I was doing in the book. The next chapter
has you doing the same thing but with a MySQL database.

Thanks all!!
Tim



On Sun, Jan 4, 2015 at 11:56 AM, Tedd Sperling <tedd@xxxxxxxxxxxx> wrote:

> Tim:
>
> > On 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.
>
> A text file to hold the orders of a fictional online store? That's not the
> way I would do it.
>
> My advice, take everything to a MySQL database. Place your Product,
> Customers, and Sales in different tables. That way it will become a simple
> matter to keep track of everything.
>
>
> > 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.
>
> -snip-
>
> Try using CSS in your forms and thus take the styling out of them.
> Remember to separate content from presentation -- it will make your code
> much easier to debug.
>
> Cheers,
>
> tedd
>
> _______________
> tedd sperling
> tedd@xxxxxxxxxxxx
>
>
>
>
>
>


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