Jump to content

[SOLVED] Problem with php estimate


a-mo

Recommended Posts

Hi,

 

I'm new here so I'm not sure sure to post in the right place or in the right way.

I have a problem. I'm trying to propose an on-line estimate on my site, using php. The problem is the "echo" at the end of the script doesn't seem to echo anything.

 

Here's the code:

 

<?php

 

function indication()

 

{

 

$Input=array();

$Input[0]=$_GET["ecma"];

$Input[1]=$_GET["php"];

 

$IndexSum=array_sum($Input);

$Index=$IndexSum+1;

 

$PageNb=$_GET["page_nb"];

$PageTran=$PageNb*90;

$Pages=$PageTran+180;

 

$Total=$Pages*$Index;

 

echo $Total;

}

 

?>

 

Any ideas?

 

I'm new to php, it may be something obvious.

 

Many thanks.

Link to comment
Share on other sites

3 pointers:

 

1.  Why is it a function?  I see no point in having this a function.

 

2.  Why go through all that trouble of making like, 3 arrays and doing simple arithmetic when you can just do:

 

<?php
$index = ($_GET['ecma'] + $_GET['php']) + 1;
$pages = ($_GET['page_nb'] * 90) + 180;
echo $index * $pages;
?>

 

3.  I'd really suggest starting variables with a lowercase letter and then use camelCase. It makes it easier to not lose track of a variable's case.

Link to comment
Share on other sites

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.