Welcome! Log In Create A New Profile

Advanced

Task 2C

Posted by Johannah 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Task 2C
March 18, 2008 08:37AM
I have completed Task 2C
Task 3A
March 18, 2008 08:44AM
I have completed Task 3A
Task 3B
March 18, 2008 08:47AM
I have completed Task 3B
Task 3C
March 18, 2008 08:49AM
I have completed Tas 3C
Re: Task 2C
April 28, 2008 12:57AM
Task 2c was pretty simple although functions for me wasn't too great at the time. But makes programming so much easier as well as to REUSE code. And that is in my opinion all programmers dream. Not to type the same code over and over.

Task 3A- 3C done smile

include files are great and makes it easy to program over multiple pages.
Please HELP!!!!
May 06, 2008 09:33AM
Ok i skipped this task because i couldn't figure out whats i am doing wrong....can anyone please tell me??


this is the function.php code that was given to us to write


<html>
<head><title>Calculating the purchase price</title></head>
<body>
<!--INSERT CODE HERE-->

<?php

function total ($price,$items)
{
$cost = $price * $items;
return $cost;
}

echo "The total price of your purchase is $" . (total($price,$items));
echo ".";

?>



</body>
</html>






and here is the cost.html page that was given to us on the disk....
When i run the application the results are always $0....??

HELP???



<html>
<head></head>
<body>
<form method='GET' action='function.php'>
How much does the book cost?
<input name='price' TYPE='text'>
<br>
How many copies of the book are you purchasing?
<input name='items' TYPE='text'>
<br>
<br>
<input type='submit'>
</form>
</body>
</html>
Re: Please HELP!!!!
May 06, 2008 09:57AM
Hi.

I tried your code. I get 0$ as the price also but you did not recive the form values in function.php so as it stands the variales are blank.
COST.html sent the values but function.php had no way of receiving them.

See the first 2 lines under <?php
Your form uses GET.
It works on mine with that.

<?php

$price = $_GET['price'];
$items = $_GET['items'];

function total ($price,$items)
{
$cost = $price * $items;
return $cost;
}

echo "The total price of your purchase is $" . (total($price,$items));
echo ".";

?>

Hope it helps smile
Re: Please HELP!!!!
May 06, 2008 11:22AM
thanks a billion thats perfect smiling smiley i get it
Re: Please HELP!!!!
May 06, 2008 11:26AM
smile Anytime
Sorry, only registered users may post in this forum.

Click here to login