html - php: dynamic link appends content to existing page rather than opening new one -


i have dynamic link fetches invoice detail based on invoice id.

<a href='<?php echo $_server['php_self']; ?>/retrieve?class=invoicelineitems&amp;id=<?php echo $invoice['invoice_id']; ?>'><?php echo $invoice['invoice_number']; ?></a>&nbsp;<?php echo $invoice['customer_name'] ?>&nbsp;<?php echo $invoice['invoice_date'] ?> 

it calls function

public function retrieve($class,         $id = null) {     switch ($class) {         case 'invoice':             $invoices = $this->invoice->getinvoices();             include 'view/invoicelist.php';             break;         case 'invoicelineitems':             $partnerinfo = $this->partnerinfo->getpartnerinfo($id);             $invoicelineitems = $this->invoicelineitems->getinvoicelineitems($id);             include 'view/invoice.php';             break;     } } 

however, include statement found in case 'invoicelineitems:' appends content of invoice.php bottom of existing page rather replacing altogether. i've tried adding target anchor, didn't work. how link open new page?

update: based on @sixeightzero suggestion, here call retrieve();

        if (isset($_request['id'])) {              //          request id value indicates arrival here through link.             $this->retrieve('invoicelineitems',                     $_request['id']);         } 

also, tried using header redirect.

ob_start(); header('location: /view/invoice.php', 302); ob_end_flush(); exit(); 

it redirects, lose access array variables from

$invoicelineitems = $this->invoicelineitems->getinvoicelineitems($id); 

so, errors

notice: undefined variable: partnerinfo in c:\xampp\htdocs\bp\view\invoice.php on line 25

and

warning: invalid argument supplied foreach() in c:\xampp\htdocs\bp\view\invoice.php on line 25

put exit(); @ end of function stop executing code after calling it.

or better still use invoice.php display invoices instead of current page.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -