This topic is locked
[SOLVED]

 Advanced mathematics

12/17/2009 1:12:09 PM
PHPRunner General questions
J
johndf author

Dear All, I am an engineer trying to calculate complex numbers and trying to figure out how to do it in phprunner attached to a mysql database.

For example I have created a project with one table. Called table1. In table1 I have 3 columns Field names Col1, Col2, Col3 each is a decimal size 32.

I now need to take Col1 add it to Col2 and take the square root of that total number and show it in Col3 for each row in the list page. This result will be shown in Col3 on each row.

My reading of the forum so far has drawn a blank, as my reading of subsequent PHP books and the PDF manual.

Now going slow for an old engineer who once taught slide rule. I have figured that the code to do this goes in the Editor, properties. Custom 'view as' settings for Col3.

where it says at the top $value= strtoupper($value)...which suggests its php language? Bu that's as far as I have reached in the programme.

PHP books suggests that some mathematical functions are possible such as log10, sqrt...not sure as to advanced functions such as Sine Cosine Tan yet but one step as at a time.

Many thanks

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=13369&image=1&table=forumtopics' class='bbc_emoticon' alt=':unsure:' />

A
alang 12/17/2009

Check out the online PHP manual - http://www.php.net/manual/en/ref.math.php
(From another old engineer 1956ag <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=46240&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' /> )

J
johndf author 12/17/2009



Check out the online PHP manual - http://www.php.net/manual/en/ref.math.php
(From another old engineer 1956ag <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=46242&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' /> )

J
johndf author 12/17/2009

My guess was right its php and it goes in the right box (Editor properties) now just got to figure out the other two parts of the problem out..Just what goes where? Many thanks from a fellow Brisbane engineer.

J
Jane 12/18/2009

Hi,
use Custom format on the "View as" settings dialog on theVisual Editor tab for this purpose.

Here is a sample:

global $data;

$value = sqrt($data["Col1"]+$data["Col2"]);



More info here:

http://www.xlinesoft.com/phprunner/docs/_view_as__settings_custom.htm

J
johndf author 12/18/2009



Hi,
use Custom format on the "View as" settings dialog on theVisual Editor tab for this purpose.

Here is a sample:

global $data;

$value = sqrt($data["Col1"]+$data["Col2"]);



More info here:

http://www.xlinesoft.com/phprunner/docs/_view_as__settings_custom.htm


So ...........use Custom format on the "View as" settings dialog on the Visual Editor tab for this purpose.got that...........
Ha haaa knew this was the correct place. The Manual is a little confusing and uses a lot of short hand.
global $data;
This names and sets $data as a variable inside a fuction that also exists outside that fuction.

The global statement brings an outside variable "into" a function.
So that something outside is Col1 and Col2.....please bring them in and call them $data ["Col1"] and ["Col2"]
Now that variable we will call the result of adding them together we will call $value
and $value is the sum of the other two.
$value = sqrt($data["Col1"]+$data["Col2"]);
ok will try that...

many thanks

jf

T
thesofa 12/20/2009

just a question here, if the values in col1 and col2 are to be added together, thern the root calculated, why do you need to store it in the table, it seems to me to be redundant fata, anytime you need the value from col3, you could calculate it on the fly.

Would that not work better?

J
johndf author 12/20/2009



just a question here, if the values in col1 and col2 are to be added together, thern the root calculated, why do you need to store it in the table, it seems to me to be redundant fata, anytime you need the value from col3, you could calculate it on the fly.

Would that not work better?


Thanks for taking the time to reply, most appreciated, but I am not sure I understand what you mean here.

I have seen this this sort of generic answer before and I guess you are trying to give advice, could you be more direct, it would be most appreciated. (from an Ex smoggie now in Aus). Remember there are a lot of new starters reading these posts for many years so any little tips are most useful. (I know I search and read these posts many times). Q1. When would you not store data?.......Q2 when would you store data.. Q3...what is redundant data Q4 how do you calculate on the fly...Many thanks

J
jdu001 12/21/2009



Thanks for taking the time to reply, most appreciated, but I am not sure I understand what you mean here.

I have seen this this sort of generic answer before and I guess you are trying to give advice, could you be more direct, it would be most appreciated. (from an Ex smoggie now in Aus). Remember there are a lot of new starters reading these posts for many years so any little tips are most useful. (I know I search and read these posts many times). Q1. When would you not store data?.......Q2 when would you store data.. Q3...what is redundant data Q4 how do you calculate on the fly...Many thanks


Q1: You don't store data when you don't need it or when the data can be retrieved from other data. In your case you don't have to save col3.
Q2: All data that you use and what is important for the application.
Q3: col3 is redundant data because you don't need it. You can calculate it everytime you need. In this case you have to calculate col3 everytime you change col1 or col2, otherwise col3 isn't correct. If you don't store col3 you can calculate the result only then when you need it. This is also the answer to Q4: on the fly means just when you need it.

Also redundant data is when you store the same data in different tables (Name in table1 and table2).

The process in making a correct datamodel is called normalisation. (http://en.wikipedia.org/wiki/Database_normalization)
I hope these answers helped you.
Greetings,
Jo

T
thesofa 12/21/2009

Wot he said!

Thanks Jo

Greeting Smog Monster! Bet aus is nicer than Teesside?
For an example, lets look at an application where we are ordering various things from a supplier.

I run a school network and I have to order supplies and equipment for all the departments, so I have written an orders database application

I could have made it a flat table application where I kept all the info for each order in one record, but then I would have to enter the suppliers name and address etc each time I ordered from them, so I have normalised the tables, so I only enter an item once into one table, where possible.

So I have a table of Departments, each order can only be for one department ( Bursar says so), So I have a look up table of departments

Each order can only be to one supplier, I also have a look up table of suppliers

Each order can be for many items,

Items may be split across 1 or more deliveries

Each delivery will only correspond to one order.
A table of orders which carries the departmental code for each order, as well as the supplier code.

The supplier table is the master table for the order_lines table, each record of which carries the order_code from the order table.

The order_lines table is the master table for the delivery notes table

The delivery notes table carries the order_lines code from the order_lines table.

My application has a main page of deparments, I chose the department and the supplier from the tables, creating an order.

then I select that order and add order lines.

The application sums the order total and counts the total number of items.

Office staff then place the order through the official dinosaur-like order system, allocating my order a number.

They add the official order number to the order record, mark the order as processed and fax the order through to the supplier.

When the goods are delivered, I add the delivery note number to the order_lines table, there maybe more than one delivery note per item.

It takes a bit more coding from the start, but not much, and as 5.2 includes master and slave addition all in one form, I guess even less code now.

It is really fast, I can pull reports for a supplier or deparment really easily and I know that it is as tight as I can get it.
The next step is to link my tables to suppliers price lists so I can have up to the minute price info, but that will be a while off.

I hope this explanation has helped rather than muddied the water.
As always, Magpies help when they can, even tho we beat the smoggies this weekend!!

J
johndf author 12/21/2009



Wot he said!

Thanks Jo

Greeting Smog Monster! Bet aus is nicer than Teesside?
For an example, lets look at an application where we are ordering various things from a supplier.

I run a school network and I have to order supplies and equipment for all the departments, so I have written an orders database application

I could have made it a flat table application where I kept all the info for each order in one record, but then I would have to enter the suppliers name and address etc each time I ordered from them, so I have normalised the tables, so I only enter an item once into one table, where possible.

So I have a table of Departments, each order can only be for one department ( Bursar says so), So I have a look up table of departments

Each order can only be to one supplier, I also have a look up table of suppliers

Each order can be for many items,

Items may be split across 1 or more deliveries

Each delivery will only correspond to one order.
A table of orders which carries the departmental code for each order, as well as the supplier code.

The supplier table is the master table for the order_lines table, each record of which carries the order_code from the order table.

The order_lines table is the master table for the delivery notes table

The delivery notes table carries the order_lines code from the order_lines table.

My application has a main page of deparments, I chose the department and the supplier from the tables, creating an order.

then I select that order and add order lines.

The application sums the order total and counts the total number of items.

Office staff then place the order through the official dinosaur-like order system, allocating my order a number.

They add the official order number to the order record, mark the order as processed and fax the order through to the supplier.

When the goods are delivered, I add the delivery note number to the order_lines table, there maybe more than one delivery note per item.

It takes a bit more coding from the start, but not much, and as 5.2 includes master and slave addition all in one form, I guess even less code now.

It is really fast, I can pull reports for a supplier or deparment really easily and I know that it is as tight as I can get it.
The next step is to link my tables to suppliers price lists so I can have up to the minute price info, but that will be a while off.

I hope this explanation has helped rather than muddied the water.
As always, Magpies help when they can, even tho we beat the smoggies this weekend!!


Wow many thanks, I will disect this carefully and go over it with a fine toothcomb in order to understand this relational database stuff, I realize I am swimming in deep database water eh.

So on a practical note if I store only the data I enter and calculate "on the fly" where in phprunner do I past the "global $data;

$value = sqrt($data["Col1"]+$data["Col2"]);" code.......so that the result will show on the report or screen? I have some rather large and complex calculations to complete.

(Extreme value statistics dealing with the extreme deviations from the median of probability distributions). This application is less about orders and suppliers and more number crunching.

J
jdu001 12/22/2009

Hello,
I will try to make an example with screenshots from every step.

But this has to wait until wednesday. I hope you can wait until then.
Greetings,
Jo

J
johndf author 12/27/2009



Hello,
I will try to make an example with screenshots from every step.

But this has to wait until wednesday. I hope you can wait until then.
Greetings,
Jo


Looking forward to it.

Merry Christmas and happy 2010

J
jdu001 12/28/2009

Hello,
I have made a document with all the screenprints, but I can't enclose it in this message.
If you send me your email-adress to jovanduin@ziggo.nl I will send you the document directly.
Greetings,
o van Duin