This topic is locked

Calculation .... what to do ?

5/1/2010 5:04:41 AM
PHPRunner General questions
O
overmars author

Dear Friends,
I have two tables with the following fields :

TABLE-1

  • no_news
  • media_name
  • size
  • color
  • ad_value



TABLE-2

  • media_id
  • media_name
  • price_bw
  • price_fc


( the tables are connected with inner joint via media_name field)

I want to automatically fill in fields ad_value from TABLE-1 with conditions :

If color = Y, Ad_value = size price_fc

If color = N, Ad_value = size
price_bw


( price_fc and price_bw take from TABLE-2)
I need suggest a simple way to realize that needs ...
thanks
Ovrs

J
Jane 5/3/2010

Hari,
you need to select values from another table in this event. Here is sample:

global $dal;

$table2 = $dal->Table("TABLE-2");

$rstmp = $table2->Query("media_name='".$values["media_name"]."'","");

$datatmp = db_fetch_array($rstmp);
if ($values["color"] == 'Y')

$values["Ad_value"] = $datatmp["price_fc"]* $values["size"];

elseif ($values["color"] == 'N')

$values["Ad_value"] = $datatmp["price_bw"]* $values["size"];
O
overmars author 5/3/2010

Jane,
I has place this code in event before edit. but still not working .... <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=49508&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />
rgds.



Hari,
you need to select values from another table in this event. Here is sample:

global $dal;

$table2 = $dal->Table("TABLE-2");

$rstmp = $table2->Query("media_name='".$values["media_name"]."'","");

$datatmp = db_fetch_array($rstmp);
if ($values["color"] == 'Y')

$values["Ad_value"] = $datatmp["price_fc"]* $values["size"];

elseif ($values["color"] == 'N')

$values["Ad_value"] = $datatmp["price_bw"]* $values["size"];


Sergey Kornilov admin 5/3/2010

Post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.