This topic is locked
[SOLVED]

 Show calculated fields on chart page

2/14/2017 4:08:24 AM
PHPRunner General questions
scottyrussell author

Hi all,
I'm currently working on a project where I display a chart generated by a search query (which works fine) and below the chart I would like to display some additional fields which I've modified my SQL Query to produce - e.g. avg, top_quartile , minimum.
Can anyone give me an example how to display these fields in the area below the chart? I've tried snippets and "View as custom" with no success <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=24470&image=1&table=forumtopics' class='bbc_emoticon' alt=':(' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=24470&image=2&table=forumtopics' class='bbc_emoticon' alt=':(' /> .
Any help would be greatly appreciated!

admin 2/14/2017

The chart itself is not designed to display anything but charts. Your best bet probably is to add a code snippet to chart page in Visual Editor, perform calculations there and display results on the page.

scottyrussell author 2/14/2017

Thanks Sergey, I thought code snippets were the way to go.
I used the snippet below:

_
global $pageObject;
$record = $pageObject->getCurrentRecord();
echo $record["cc_average"];

____

"cc_average" is my calculated field, I tried it within the {chart_block} and also outside and I still got a blank.

Am I using the wrong code? Can you point me in the right direction?

admin 2/15/2017

There is no current record on chart page, charts normally work with multiple records or even with aggregated results. You cannot use getCurrentRecord() there.
Your best bet is to execute the same SQL Query in your code snippet that you use to populate chart, and do something with that data this query returns.

lefty 2/15/2017



The chart itself is not designed to display anything but charts. Your best bet probably is to add a code snippet to chart page in Visual Editor, perform calculations there and display results on the page.



Create a custom view of your table , then create dashboard of your table using custom view , Query your totals in query designer using same calculations as your chart except total fields in your dashboard table , and add your chart to dashboard above your totals on the list page.Note: just show your alias's for totals on the list page .
charts with dashboard

scottyrussell author 2/15/2017



There is no current record on chart page, charts normally work with multiple records or even with aggregated results. You cannot use getCurrentRecord() there.
Your best bet is to execute the same SQL Query in your code snippet that you use to populate chart, and do something with that data this query returns.


Hi Sergey,
I am going down the SQL query path (I have to get use the search variables form over 40 dropdowns!! accessing multiple tables), in a previous project I was able to grab a search variable to display by using a Before Display event (Jane hooked me up with some prime code when a couple of years ago! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=81354&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' /> similar to this example in the manual). So I decided to recycle this code to test using just a few variables:

global $strTableName;

if (isset($_SESSION[$strTableName.'_advsearch']))

{

$searchClauseObj = unserialize($_SESSION[$strTableName.'_advsearch']);

}



$fieldSearchData = $searchClauseObj->_where[$strTableName."_srchFields"];
for($i=0; $i<count($fieldSearchData); $i++){

$fName = $fieldSearchData[$i]['fName'];

$val1 = $fieldSearchData[$i]['value1'];

$val2 = $fieldSearchData[$i]['value2'];

$srchCat = $fieldSearchData[$i]['opt'];

$srchNot = $fieldSearchData[$i]['not'];

if ($fName=="calc_value_s01_cc")

$_SESSION["calc_value_s01_cc"] = $val1;

if ($fName=="calc_value_s02_cc")

$_SESSION["calc_value_s02_cc"] =$val1;

if ($fName=="value_num1")

$_SESSION["value_num1"] = $val1;

if ($fName=="value_num2")

$_SESSION["value_num2"] =$val1;

if ($fName=="value_num8")

$_SESSION["value_num8"] =$val1;

}

$rstmp = CustomQuery("SELECT 288.023287900342 * (dbo.mrwin_s01_sow_cc.calc_value_s01_cc + dbo.mrwin_s02_sow_cc.calc_value_s02_cc) * dbo.mrwin_servers.value_num * dbo.mrwin_sla_availability_cc.value_num * dbo.mrwin_sla_reliability_cc.value_num FROM

dbo.mrwin_s01_sow_cc

, dbo.mrwin_s02_sow_cc

, dbo.mrwin_servers

, dbo.mrwin_sla_availability_cc

, dbo.mrwin_sla_reliability_cc

WHERE

dbo.mrwin_s01_sow_cc.calc_value_s01_cc = '".$_SESSION['calc_value_s01_cc']."'

AND

dbo.mrwin_s02_sow_cc.calc_value_s02_cc = '".$_SESSION['calc_value_s02_cc']."'

AND

dbo.mrwin_servers.value_num = '".$_SESSION['value_num1']."'

AND

dbo.mrwin_sla_availability_cc.value_num = '".$_SESSION['value_num2']."'

AND

dbo.mrwin_sla_reliability_cc.value_num = '".$_SESSION['value_num3']."'");

$datatmp = db_fetch_array($rstmp);

$xt->assign("cc_special_topline",$datatmp["cc_special"]);


It hangs up at the WHERE statement -

dbo.mrwin_s01_sow_cc.calc_value_s01_cc = '".$_SESSION['calc_value_s01_cc']."'


Error type 256

Error description Source: Microsoft SQL Server Native Client 11.0

Description: Error converting data type varchar to numeric.
I have tried several combinations of the syntax, removing quotes and periods but I can get it to process.
Am I on the right track? Is it just my placement of quotes? Can anyone help with the correct syntax for my where statement?
I appreciate any help I as I feel am so close to an outcome!

lefty 2/16/2017



Hi Sergey,
I am going down the SQL query path (I have to get use the search variables form over 40 dropdowns!! accessing multiple tables), in a previous project I was able to grab a search variable to display by using a Before Display event (Jane hooked me up with some prime code when a couple of years ago! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=81357&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' /> similar to this example in the manual). So I decided to recycle this code to test using just a few variables:

global $strTableName;

if (isset($_SESSION[$strTableName.'_advsearch']))

{

$searchClauseObj = unserialize($_SESSION[$strTableName.'_advsearch']);

}
$fieldSearchData = $searchClauseObj->_where[$strTableName."_srchFields"];
for($i=0; $i<count($fieldSearchData); $i++){

$fName = $fieldSearchData[$i]['fName'];

$val1 = $fieldSearchData[$i]['value1'];

$val2 = $fieldSearchData[$i]['value2'];

$srchCat = $fieldSearchData[$i]['opt'];

$srchNot = $fieldSearchData[$i]['not'];

if ($fName=="calc_value_s01_cc")

$_SESSION["calc_value_s01_cc"] = $val1;

if ($fName=="calc_value_s02_cc")

$_SESSION["calc_value_s02_cc"] =$val1;

if ($fName=="value_num1")

$_SESSION["value_num1"] = $val1;

if ($fName=="value_num2")

$_SESSION["value_num2"] =$val1;

if ($fName=="value_num8")

$_SESSION["value_num8"] =$val1;

}

$rstmp = CustomQuery("SELECT 288.023287900342 * (dbo.mrwin_s01_sow_cc.calc_value_s01_cc + dbo.mrwin_s02_sow_cc.calc_value_s02_cc) * dbo.mrwin_servers.value_num * dbo.mrwin_sla_availability_cc.value_num * dbo.mrwin_sla_reliability_cc.value_num FROM

dbo.mrwin_s01_sow_cc

, dbo.mrwin_s02_sow_cc

, dbo.mrwin_servers

, dbo.mrwin_sla_availability_cc

, dbo.mrwin_sla_reliability_cc

WHERE

dbo.mrwin_s01_sow_cc.calc_value_s01_cc = '".$_SESSION['calc_value_s01_cc']."'

AND

dbo.mrwin_s02_sow_cc.calc_value_s02_cc = '".$_SESSION['calc_value_s02_cc']."'

AND

dbo.mrwin_servers.value_num = '".$_SESSION['value_num1']."'

AND

dbo.mrwin_sla_availability_cc.value_num = '".$_SESSION['value_num2']."'

AND

dbo.mrwin_sla_reliability_cc.value_num = '".$_SESSION['value_num3']."'");

$datatmp = db_fetch_array($rstmp);

$xt->assign("cc_special_topline",$datatmp["cc_special"]);


It hangs up at the WHERE statement -

dbo.mrwin_s01_sow_cc.calc_value_s01_cc = '".$_SESSION['calc_value_s01_cc']."'


Error type 256

Error description Source: Microsoft SQL Server Native Client 11.0

Description: Error converting data type varchar to numeric.
I have tried several combinations of the syntax, removing quotes and periods but I can get it to process.
Am I on the right track? Is it just my placement of quotes? Can anyone help with the correct syntax for my where statement?
I appreciate any help I as I feel am so close to an outcome!



'".$_SESSION['calc_value_s01_cc']."' // this is for text
should be for numeric
".$_SESSION['calc_value_s01_cc']." // this is for numeric

scottyrussell author 2/16/2017

Awesome!!!! thanks John, those quotes are confusing!! that sorted out the Numerical/varchar error now I am getting another error
Error type 256

Error description Source: Microsoft SQL Server Native Client 11.0

Description: Incorrect syntax near the keyword 'AND'.
I can't see anything wrong with the query syntax and am trying to work this out now, do you have any ideas?
It is saying the problem is with the last line of the query

dbo.mrwin_sla_reliability_cc.value_num = ".$_SESSION['value_num3']."");
lefty 2/16/2017



Awesome!!!! thanks John, those quotes are confusing!! that sorted out the Numerical/varchar error now I am getting another error
Error type 256

Error description Source: Microsoft SQL Server Native Client 11.0

Description: Incorrect syntax near the keyword 'AND'.
I can't see anything wrong with the query syntax and am trying to work this out now, do you have any ideas?
It is saying the problem is with the last line of the query

dbo.mrwin_sla_reliability_cc.value_num = ".$_SESSION['value_num3']."");



dbo.mrwin_sla_reliability_cc.value_num = ".$_SESSION["value_num3"]."

scottyrussell author 2/16/2017



dbo.mrwin_sla_reliability_cc.value_num = ".$_SESSION["value_num3"]."


Hi John,
Thanks for getting back to me, I wish it was this simple -
I need the additional "); to close off the SQL query.
So it still won't process the query!

scottyrussell author 2/16/2017

To simplify things I reduced the code to this:

global $strTableName;

if (isset($_SESSION[$strTableName.'_advsearch']))

{

$searchClauseObj = unserialize($_SESSION[$strTableName.'_advsearch']);

}



$fieldSearchData = $searchClauseObj->_where[$strTableName."_srchFields"];
for($i=0; $i<count($fieldSearchData); $i++){

$fName = $fieldSearchData[$i]['fName'];

$val1 = $fieldSearchData[$i]['value1'];

$val2 = $fieldSearchData[$i]['value2'];

$srchCat = $fieldSearchData[$i]['opt'];

$srchNot = $fieldSearchData[$i]['not'];

if ($fName=="calc_value_s01_cc")

$_SESSION["calc_value_s01_cc"] = $val1;

}

$rstmp = CustomQuery("SELECT 288.023287900342 * mrwin_s01_sow_cc.calc_value_s01_cc

FROM

dbo.mrwin_s01_sow_cc

WHERE

dbo.mrwin_s01_sow_cc.calc_value_s01_cc = ".$_SESSION['calc_value_s01_cc']."

");

$datatmp = db_fetch_array($rstmp);

$xt->assign("cc_special_topline",$datatmp["cc_special"]);


and when trying to run the project I got this error:
Error type 256

Error description Source: Microsoft SQL Server Native Client 11.0

Description: Incorrect syntax near '='.
so the sql calculation does not like this varible

".$_SESSION['calc_value_s01_cc']."


is this problem specific to MS SQL, perhaps a bug?

admin 2/21/2017

This problem is specific to your code. Instead of executing SQL query print it on the page and see what is missing.

scottyrussell author 2/21/2017

Thanks Sergey, I got back into this today creating a test set of data and using the debugging tools.
Here's my current code



global $strTableName;

if (isset($_SESSION[$strTableName.'_advsearch']))

{

$searchClauseObj = unserialize($_SESSION[$strTableName.'_advsearch']);

}



$fieldSearchData = $searchClauseObj->_where[$strTableName."_srchFields"];
for($i=0; $i<count($fieldSearchData); $i++){

$fName = $fieldSearchData[$i]['fName'];

$val1 = $fieldSearchData[$i]['value1'];

$val2 = $fieldSearchData[$i]['value2'];

$srchCat = $fieldSearchData[$i]['opt'];

$srchNot = $fieldSearchData[$i]['not'];

if ($fName=="xf1_value")

$_SESSION["xf1_value"] = $val1;

if ($fName=="xf2_value")

$_SESSION["xf2_value"] = $val1;

if ($fName=="xf3_value")

$_SESSION["xf3_value"] = $val1;

if ($fName=="yf1_value")

$_SESSION["yf1_value"] = $val1;

if ($fName=="yf2_value")

$_SESSION["yf2_value"] = $val1;

}

$rstmp = CustomQuery("SELECT 100 * ( dbo.aalab_xfactor1.xf1_value + dbo.aalab_xfactor2.xf2_value + dbo.aalab_xfactor3.xf3_value ) * dbo.aalab_yfactor1.yf1_value * dbo.aalab_yfactor2.yf2_value

FROM

dbo.aalab_xfactor1

, dbo.aalab_xfactor2

, dbo.aalab_xfactor3

, dbo.aalab_yfactor1

, dbo.aalab_yfactor2

WHERE

dbo.aalab_xfactor1.xf1_value = $_SESSION[xf1_value]

AND

dbo.aalab_xfactor2.xf2_value = $_SESSION[xf2_value]

AND

dbo.aalab_xfactor3.xf3_value = $_SESSION[xf3_value]

AND

dbo.aalab_yfactor1.yf1_value = $_SESSION[yf1_value]

AND

dbo.aalab_yfactor2.yf2_value = $_SESSION[yf2_value] ");

$datatmp = db_fetch_array($rstmp);

$xt->assign("special_number_topline",$datatmp["special_number"]);


This code placed in the Before Display Event and is supposed to assign the result of the query to a field {$special_number_topline}
If I access the report from login I get this error
Error description Source: Microsoft SQL Server Native Client 11.0

Description: Incorrect syntax near the keyword '=' (it is getting upset because there is no data)
However if I run the report from a url with data in it (i.e. http://localhost:8085/Report_v_2_report.php?q=(xf1_value~equals~0.05)(xf2_value~equals~0.12)(xf3_value~equals~0.12)(yf1_value~equals~1)(yf2_value~equals~0.6)) the page report loads.
Using the debugger I can see that my query runs as expected -
the debugger shows this: SELECT 100 ( dbo.aalab_xfactor1.xf1_value + dbo.aalab_xfactor2.xf2_value + dbo.aalab_xfactor3.xf3_value ) dbo.aalab_yfactor1.yf1_value * dbo.aalab_yfactor2.yf2_value FROM dbo.aalab_xfactor1 , dbo.aalab_xfactor2 , dbo.aalab_xfactor3 , dbo.aalab_yfactor1 , dbo.aalab_yfactor2 WHERE dbo.aalab_xfactor1.xf1_value = 0.05 AND dbo.aalab_xfactor2.xf2_value = 0.12 AND dbo.aalab_xfactor3.xf3_value = 0.12 AND dbo.aalab_yfactor1.yf1_value = 1 AND dbo.aalab_yfactor2.yf2_value = 0.6
So my query WORKS!! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=81409&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' /> as long as there is already data available <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=81409&image=2&table=forumreplies' class='bbc_emoticon' alt=':(' />
However when it works my field {$special_number_topline} is still empty. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=81409&image=3&table=forumreplies' class='bbc_emoticon' alt=':(' />
So I have 2 challenges:

  1. How to have the query in the Before Display Event without it crashing the app. (can we tell it it's ok to not have any data until we've run a search)
  2. How to print the result as my created field is not working!
    Also I tried placing the whole code in a snippet as well as splitting out the query part into a snippet and the result was the whole thing froze up!
    So is there something obvious that I am doing wrong?

lefty 2/22/2017



Thanks Sergey, I got back into this today creating a test set of data and using the debugging tools.
Here's my current code



global $strTableName;

if (isset($_SESSION[$strTableName.'_advsearch']))

{

$searchClauseObj = unserialize($_SESSION[$strTableName.'_advsearch']);

}
$fieldSearchData = $searchClauseObj->_where[$strTableName."_srchFields"];
for($i=0; $i<count($fieldSearchData); $i++){

$fName = $fieldSearchData[$i]['fName'];

$val1 = $fieldSearchData[$i]['value1'];

$val2 = $fieldSearchData[$i]['value2'];

$srchCat = $fieldSearchData[$i]['opt'];

$srchNot = $fieldSearchData[$i]['not'];

if ($fName=="xf1_value")

$_SESSION["xf1_value"] = $val1;

if ($fName=="xf2_value")

$_SESSION["xf2_value"] = $val1;

if ($fName=="xf3_value")

$_SESSION["xf3_value"] = $val1;

if ($fName=="yf1_value")

$_SESSION["yf1_value"] = $val1;

if ($fName=="yf2_value")

$_SESSION["yf2_value"] = $val1;

}

$rstmp = CustomQuery("SELECT 100 * ( dbo.aalab_xfactor1.xf1_value + dbo.aalab_xfactor2.xf2_value + dbo.aalab_xfactor3.xf3_value ) * dbo.aalab_yfactor1.yf1_value * dbo.aalab_yfactor2.yf2_value

FROM

dbo.aalab_xfactor1

, dbo.aalab_xfactor2

, dbo.aalab_xfactor3

, dbo.aalab_yfactor1

, dbo.aalab_yfactor2

WHERE

dbo.aalab_xfactor1.xf1_value = $_SESSION[xf1_value]

AND

dbo.aalab_xfactor2.xf2_value = $_SESSION[xf2_value]

AND

dbo.aalab_xfactor3.xf3_value = $_SESSION[xf3_value]

AND

dbo.aalab_yfactor1.yf1_value = $_SESSION[yf1_value]

AND

dbo.aalab_yfactor2.yf2_value = $_SESSION[yf2_value] ");

$datatmp = db_fetch_array($rstmp);

$xt->assign("special_number_topline",$datatmp["special_number"]);


This code placed in the Before Display Event and is supposed to assign the result of the query to a field {$special_number_topline}
If I access the report from login I get this error
Error description Source: Microsoft SQL Server Native Client 11.0

Description: Incorrect syntax near the keyword '=' (it is getting upset because there is no data)
However if I run the report from a url with data in it (i.e. http://localhost:8085/Report_v_2_report.php?q=(xf1_value~equals~0.05)(xf2_value~equals~0.12)(xf3_value~equals~0.12)(yf1_value~equals~1)(yf2_value~equals~0.6)) the page report loads.
Using the debugger I can see that my query runs as expected -
the debugger shows this: SELECT 100 ( dbo.aalab_xfactor1.xf1_value + dbo.aalab_xfactor2.xf2_value + dbo.aalab_xfactor3.xf3_value ) dbo.aalab_yfactor1.yf1_value * dbo.aalab_yfactor2.yf2_value FROM dbo.aalab_xfactor1 , dbo.aalab_xfactor2 , dbo.aalab_xfactor3 , dbo.aalab_yfactor1 , dbo.aalab_yfactor2 WHERE dbo.aalab_xfactor1.xf1_value = 0.05 AND dbo.aalab_xfactor2.xf2_value = 0.12 AND dbo.aalab_xfactor3.xf3_value = 0.12 AND dbo.aalab_yfactor1.yf1_value = 1 AND dbo.aalab_yfactor2.yf2_value = 0.6
So my query WORKS!! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=81411&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' /> as long as there is already data available <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=81411&image=2&table=forumreplies' class='bbc_emoticon' alt=':(' />
However when it works my field {$special_number_topline} is still empty. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=81411&image=3&table=forumreplies' class='bbc_emoticon' alt=':(' />
So I have 2 challenges:

  1. How to have the query in the Before Display Event without it crashing the app. (can we tell it it's ok to not have any data until we've run a search)
  2. How to print the result as my created field is not working!
    Also I tried placing the whole code in a snippet as well as splitting out the query part into a snippet and the result was the whole thing froze up!
    So is there something obvious that I am doing wrong?



After looking at this further . I still don't see why you just don't use a custom view run a query for your totals and get your results from there much easier, Then use events to get the data you need search, etc.... The original question was to get totals in your chart . This can be done easily with a custom view and chart above in dashboard. Then add your special variable in before display xt assign.
$xt->assign("special_number_topline",$datatmp["special_number"]); // in before display event. if it is defined somewhere. I don't see special_numbertopline anywhere. Maybe a screenshot of your html page will help or the snippet you included?
Also note that if this is a report
RE:

"If I access the *
report* from login I get this error"
"From the manual" for reports if you are using ENTERPRISE EDITION as I don't see here anywhere what version of phprunner you are using . Maybe I missed it .
On this page you can choose a table, view or SQL query as a datasource for your report. Note that tables that are not added to the project from a database are not available for selection.
Tables from the database
· All tables added to the project are available for selection. User tables (custom views) are not available.
· When viewing a report, all user permissions (static and dynamic permissions, advanced security option) and "view/edit" field settings do not work.
· While creating a report you will be able to create table relations (SQL joins) to query data from two or more tables and add additional search conditions using WHERE clause.
Tables from the project
· All tables added to the project and custom views created in PHPRunner are available for selection.
· When viewing a report, user permissions and "view/edit" field settings work as usual.
·
While creating a report you will not be able to create table relations (SQL joins) to query data from two or more tables and add additional search conditions using WHERE clause. The SQL queries defined in PHPRunner will be used to query data for report._
Hope this helps a little!

scottyrussell author 2/22/2017

Hi John,
phprunner, enterprise edition , v9.6.
I get the same errors whether I run this as a Report or a Chart.
I'm more confused then ever, all I want to do is write a query based on the results of a search and present the information under the chart.
The results and charts are dynamic, i.e. based on search so it is not a simple list exercise where I pull the information from a database.
Thanks for your help so far. I will investigate the dashboard option, I just feel I have even less control over the presentation layer with the dashboard.

scottyrussell author 2/22/2017

All righty!! I've worked it out!!
As I had done something similar in MySQL I decided to replicate the project in MySQL. After a bit of trial and error I got it.
Here is the code for the Before Display Event - this works in MySQL or MSSQL:



global $strTableName;

if (isset($_SESSION[$strTableName.'_advsearch']))

{

$searchClauseObj = unserialize($_SESSION[$strTableName.'_advsearch']);

}



$fieldSearchData = $searchClauseObj->_where[$strTableName."_srchFields"];
for($i=0; $i<count($fieldSearchData); $i++){

$fName = $fieldSearchData[$i]['fName'];

$val1 = $fieldSearchData[$i]['value1'];

$val2 = $fieldSearchData[$i]['value2'];

$srchCat = $fieldSearchData[$i]['opt'];

$srchNot = $fieldSearchData[$i]['not'];

if ($fName=="xf1_value")

$_SESSION["xf1_value"] = $val1;

if ($fName=="xf2_value")

$_SESSION["xf2_value"] = $val1;

if ($fName=="xf3_value")

$_SESSION["xf3_value"] = $val1;

if ($fName=="yf1_value")

$_SESSION["yf1_value"] = $val1;

if ($fName=="yf2_value")

$_SESSION["yf2_value"] = $val1;

}


Then I put the query and the echo in a snippet, the catch was that for MSSQL I had to process the numeric values as varchar using the CAST function, MySQL did not require this. I also changed the code by including the AS function and calling on the value via echo rather than trying to assign it with $xt->assign.
Snippet - MySQL version



$rstmp = CustomQuery("SELECT 100 * ( xfactor1.xf1_value + xfactor2.xf2_value + xfactor3.xf3_value ) * yfactor1.yf1_value * yfactor2.yf2_value

AS special_number

FROM

xfactor1

, xfactor2

, xfactor3

, yfactor1

, yfactor2

WHERE

xfactor1.xf1_value = '".$_SESSION["xf1_value"]."'

AND

xfactor2.xf2_value = '".$_SESSION["xf2_value"]."'

AND

xfactor3.xf3_value = '".$_SESSION["xf3_value"]."'

AND

yfactor1.yf1_value = '".$_SESSION["yf1_value"]."'

AND

yfactor2.yf2_value = '".$_SESSION["yf2_value"]."' ");

$datatmp = db_fetch_array($rstmp);

echo "MY NUMBER: " . $datatmp["special_number"];


Snippet - MSSQL version



$rstmp = CustomQuery("SELECT 100 * ( dbo.aalab_xfactor1.xf1_value + dbo.aalab_xfactor2.xf2_value + dbo.aalab_xfactor3.xf3_value ) * dbo.aalab_yfactor1.yf1_value * dbo.aalab_yfactor2.yf2_value

AS special_number

FROM

dbo.aalab_xfactor1

, dbo.aalab_xfactor2

, dbo.aalab_xfactor3

, dbo.aalab_yfactor1

, dbo.aalab_yfactor2

WHERE

dbo.aalab_xfactor1.xf1_value = CAST (".$_SESSION["xf1_value"]." AS VARCHAR)

AND

dbo.aalab_xfactor2.xf2_value = CAST (".$_SESSION["xf2_value"]." AS VARCHAR)

AND

dbo.aalab_xfactor3.xf3_value = CAST (".$_SESSION["xf3_value"]." AS VARCHAR)

AND

dbo.aalab_yfactor1.yf1_value = CAST (".$_SESSION["yf1_value"]." AS VARCHAR)

AND

dbo.aalab_yfactor2.yf2_value = CAST (".$_SESSION["yf2_value"]." AS VARCHAR) ");

$datatmp = db_fetch_array($rstmp);

echo "MY NUMBER: " . $datatmp["special_number"];


AND VOILA!!!
So my key learnings here are that MSSQL and MySQL have subtle but important differences in the way they interact with PHP and you need to assign a query result/value a name in order to echo it.
Thanks for your help gentlemen, I appreciate your efforts!
<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=81426&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=81426&image=2&table=forumreplies' class='bbc_emoticon' alt=':D' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=81426&image=3&table=forumreplies' class='bbc_emoticon' alt=':D' />