How to get record number

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
cahsolonomer1
User
Posts: 121

How to get record number

Post by cahsolonomer1 »

I will print by taking the record number with CurrentValue, but can't run.
how to take the record number

function ListOptions_Rendered() {
$this->ListOptions->Items["print"]->Body = "<a href='report.php?id_report=id_report->CurrentValue' target='blank'> Print</a>";
}

thanks


sangnandar
User
Posts: 980

Post by sangnandar »

You have to concat your code properly.

$body = "html-code" . $this->id->CurrentValue . "html-code-continued" ;
$this->ListOptions->Items["print"]->Body = $body ;

Don't forget to escape " (if you have any) with \"


cahsolonomer1
User
Posts: 121

Post by cahsolonomer1 »

I'm sorry, the problem not solved

this is my script :

function ListOptions_Load() {
$opt = &$this->ListOptions->Add("print");
$opt->MoveTo(0);
}

function ListOptions_Rendered() {
$body = "<a href='report.php?id_report=' " .$this->id_report->CurrentValue ."target='blank'> Print</a>" ;
$this->ListOptions->Items["print"]->Body = $body ;
}

note : the id_report not display


sangnandar
User
Posts: 980

Post by sangnandar »

Double check your code.

$body = "<a href='report.php?id_report=<don't need quote here>" .$this->id_report->CurrentValue ."<quote here and add space>target='blank'> Print</a>" ;

Here are some tips.
When you do variable concat inside a html code you better put the html first.
This is your html,
<a href='report.php?id_report=123' target='blank'> Print</a>
Then replace 123 with ".."
Then insert the variable $this->id_report->CurrentValue into ".."

It saves your from quotes headache.


cahsolonomer1
User
Posts: 121

Post by cahsolonomer1 »

if directly typed at browser report.php? id_report = 1, then successful display. report.php? id_report = 3, then successful display.
but the number 1or 3 I replace with $this->id_report->CurrentValue, can't display
maybe i am wrong in combining sintak a href.
please help. thanks


sangnandar
User
Posts: 980

Post by sangnandar »

Check the existence,
$this->ListOptions->Items["print"]->Body = $this->id_report->CurrentValue;

What do you see?


cahsolonomer1
User
Posts: 121

Post by cahsolonomer1 »

function ListOptions_Rendered() {
$body = "<a href=report.php?id_report=1' target='_blank'> Print</a>" ;
$this->ListOptions->Items["print"]->Body = $body ;
}
that is can display, just record no.1 only

function ListOptions_Rendered() {
$body = "<a href=report.php?id_report=$this->id_selang->CurrentValue' target='_blank'> Print</a>" ;
$this->ListOptions->Items["print"]->Body = $body ;
}
there is message :
Catchable fatal error: Object of class cField could not be converted to string in....

how to insert a record number in to a href syntax..?


cahsolonomer1
User
Posts: 121

Post by cahsolonomer1 »

$this->ListOptions->Items["print"]->Body = $this->id_report->CurrentValue;

display record number
1 3


sangnandar
User
Posts: 980

Post by sangnandar »

Copy-paste this code,
$body = "<a href='report.php?id_report=".$this->id_report->CurrentValue."' target='blank'> Print</a>" ;
and
$body = "<a href='report.php?id_report=".$this->id_selang->CurrentValue."' target='
blank'> Print</a>" ;


cahsolonomer1
User
Posts: 121

Post by cahsolonomer1 »

Yess.... Trouble solved..
Thanks you very muchh...


Post Reply