Jump to content

Recommended Posts

I am not attempting to have the correct codes just thrown at me but I really need to understand why I’m having the problems I am. I have several books, but they are all the same in that they tell you what functions are but not really how to use them in an applied way.

 

There are essentially three things wrong with my code. As you can see I am including another php file to pull all the information from ($petspa).

 

I have the While with the format I need. But I am unable to insert a proper table. Also I want to take each breed and do a summary of total revenue from that breed as attempted once in the For (I should just be able to repeat that For While for each breed.) Finally I need a simple array to display the single breed that brings in the most revenue, showing only its breed type and total revenue.

 

The while works, but I can’t do a simple table for it to appear organized.

The for does not work at all.

And I have no idea how to pull out an array for the single breed and total profits

 

<?php

Include 'petspainfo.php'

$breed = rtrim(strtok($pet_spa, " \n"));
$appointment = rtrim(strtok(" \n"));
$day = rtrim(strtok(" \n"));
$time = rtrim(strtok(" \n"));
$charge = rtrim(strtok(" \n"));

printf ("%9s\n", "Breed   App.   Day   Time   Charge");

while($breed){
echo $breed, " ";
echo $appointment, " ";
echo $day, " ";
echo $time, " ";
echo "\$" . number_format ($charge,2);

    $breed = rtrim(strtok(" \n"));
    echo date('M',mktime(12,0,0,$appointment,1,2009)) . "    ";
    $day = rtrim(strtok(" \n"));
    $time = rtrim(strtok(" \n"));
    $charge = rtrim(strtok(" \n"));

}

for ($breed = Lab){
echo $breed;
$charge = $charge + $charge;
echo $charge
}

?>

I haven't got to the array yet. i was hoping it would be more sefl explainatory after addressing the for problem and hopefully seeing what I was doing wrong with the tabel. I was up til 3 playing with that. I just included the need for an array because it seems asking about one detail at a time just gets more questions than comments. Ya know?

 

I just noticed I made a typo in the code

<?php

Include 'petspainfo.php'

$breed = rtrim(strtok($pet_spa, " \n"));
$appointment = rtrim(strtok(" \n"));
$day = rtrim(strtok(" \n"));
$time = rtrim(strtok(" \n"));
$charge = rtrim(strtok(" \n"));

printf ("%9s\n", "Breed   App.   Day   Time   Charge");

while($breed){
echo $breed, " ";
echo date('M',mktime(12,0,0,$appointment,1,2009)) . "    ";
echo $day, " ";
echo $time, " ";
echo "\$" . number_format ($charge,2);

    $breed = rtrim(strtok(" \n"));
    $appointment = rtrim(strtok(" \n"));
    $day = rtrim(strtok(" \n"));
    $time = rtrim(strtok(" \n"));
    $charge = rtrim(strtok(" \n"));

}

for ($breed = Lab){
echo $breed;
$charge = $charge + $charge;
echo $charge
}

?>

I haven't got to the array yet. i was hoping it would be more sefl explainatory after addressing the for problem and hopefully seeing what I was doing wrong with the tabel. I was up til 3 playing with that. I just included the need for an array because it seems asking about one detail at a time just gets more questions than comments. Ya know?

 

well first of all. you dont do for loops like that. second of all, you probably want to use the comparison operator (==) not the assignment operator (=)

 

for loops are structured (for the most part, of course there are some variations) like so

for ($counter, $counter < $timesToLoop; $counter++){

 

 

i'm not sure what you are trying to even do, but I suggest you do study the basics of PHP a little more before you tackle this problem. It will be a lot less of a headache then..

 

But for your problem. Can you describe, exactly, what works and what doesn't, and what you expect to happen.

 

 

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.