This topic is locked
[SOLVED]

 How can I access record field in a php snipplet which is

11/5/2011 1:03:39 PM
PHPRunner General questions
O
oldes author

Hi,
I would like to retrive database field value ( {$SiparisID_value} field in html) on a printer-friendly form...
I created a snipplet and call the necessary function which works fine with a constant rather than field varieable..
I realized that I $data, $values and $record globals are not accessible from snipplet.
How can I access to the database field appears onthe printer-friendly list?..



global $record;
echo constInvoiceDetailTable($record["SiparisID"],true);
C
cgphp 11/5/2011

Do a custom query:

$rs = CustomQuery("SELECT SiparisID FROM your_table_name WHERE ....");

$record = db_fetch_array($rs);
echo constInvoiceDetailTable($record["SiparisID"],true);
O
oldes author 11/6/2011

$SiparisID= {$SiparisID_value} ; //? How will I get {$SiparisID_value} in a snipplet on a printer friendly form?
echo constInvoiceDetailTable( $SiparisID ,true);


Hi Christian,

Thanks for your answer but I wasn't very clear in my question; I am sorry for that..
I have to retrieve "SiparisID" from the current record printed on a printer-friendly form so that I can retrive details records.
Therefore I need to get the value of the SiparisID field so I can crete the condition of the where statement. ("... Where SiparisID ={$SiparisID_value}) in the snipplet"
So far I couln't manage to get the value of my field "SiparisID" (a.k.a {$SiparisID_value} in html).

Sergey Kornilov admin 11/6/2011

Oldes,
the best approach is to use 'View as' Custom instead of code snippet. This way you will have access to all current record fields.
Check this article for more info, section 'View As: Custom':

http://xlinesoft.com/blog/2011/04/28/taming-the-beast-events-buttons-and-code-snippets/

O
oldes author 11/6/2011



Oldes,
the best approach is to use 'View as' Custom instead of code snippet. This way you will have access to all current record fields.
Check this article for more info, section 'View As: Custom':

http://xlinesoft.com/blog/2011/04/28/taming-the-beast-events-buttons-and-code-snippets/


Thanks Sergey, I will try this ASAP

O
oldes author 11/6/2011

Yes, It's done!
I defined a shadow field called "SipID" in the table query



SELECT

...

SiparisID,

..

SiparisID AS SipID

FROM mkb_faturalar

WHERE (FaturaTipiID =1 OR FaturaTipiID =2)

ORDER BY FaturaID DESC


Inthe printer friendly form

I set the SipID as "View as Custom" and in the code defined the following..


global $data;

$value= constInvoiceDetailTable$data["SipID"],false);


Thanks !
Hopefully I will learn PHPR <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=62087&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' />