Ajax Style Calcutaions (Custum Calculator)

Hi,

Im looking for code, or an extension, that will allow me to present the user with a link, which slides down a form from the top or side of the screen, or even in an model/lightbox which allows them to enter the following values

  • pv_value

  • mr_value

  • age

It then needs to query separate table called "matrix" in the same database to find three all 3 values in the row e.g. "r1c1","r1c2", "r1c3" where $Age=rowAge1




         col1, col2, col3

rowAge1: r1c1, r1c2, r1c3

rowAge2: r2c1, r2c2, r2c3

rowAge3: r3c1, r3c2, r3c3

THEN, armed with these 3 values from the database, it needs to do a few calculations and present the results

e.g. one calcualation would be:




$pv_value = $_POST['pv_value'];

$age = $_POST['age'];


$rev_percentage = /* SELECT col1 FROM Matrix WHERE $age=age */


$rev_value = 1000 * (($pv_value * $rev_percentage) / 100);

if ($rev_value < 0) { $rev_value = 0; }

$rev_value = number_format($rev_value);


return $rev_value;



So we’d then echo $rev_value;

Same for another two calculations…

The form should do it all in the frontend, and there’s no need to save the results… just output to screen…

Any incredibly charitable and very bored devs out there?

p

p.s. i meant Calculations and Custom, not Calcutaions and Custum, and i cant edit that title lol FML!

im getting close lol, i’ve got a Controller/Model for it now, and have got data! :lol:


<?php


$age = "65";


$connection=Yii::app()->db;


$user = Yii::app()->db->createCommand()

    ->select('*')

    ->from('matrix_er')

    ->where('age=:age', array(':age'=>$age))

    ->queryRow();


print_r($user);


?>

OK, got all my values working, now just have to submit to itself… so that user can enter the variables…

nearly there!

ok, brick wall now… I think i will come up with something tomorrow…

I;ve got a single page with all the PHP, JS etc, and the form is pur HTML, submits to itself, and the PHP loads the variables on load… so it works…

It’s also inside a sliding div (like a typical contact/feedback form) but naturally it refreshes the entire page when you submit the form.

its a horrible hacky ugly solution, but it works.

I need it to refresh via ajax, but its really hard for me to work with YII as its new to me, so i’ve made a monster hybrid lol

fed up for today, fresh mind tomorrow!