Retrieve table cell value and move to second PHP screen

0

Hello,

I have a need and I have a great difficulty with PHP, some I was able to help myself, I'm creating a table with information from the database, and inside a cell I'm putting an Onclick to open a second screen to show the detailing. I need that when the user clicks on a cell I receive the value of it on the other page. Here is the code below.

            <?php
        $SQL = "SELECT * FROM tabela where id = '$_SESSION';";
        $BSG = $CONNEXT->prepare($SQL);
        $BSG->bindValue(':usr', $USER_, PDO::PARAM_STR);
        $BSG->execute();

        while ($RESP = $BSG->fetch(PDO::FETCH_ASSOC)) {
            //header('Content-Type: text/html; charset=iso-8859-1,utf-8;q=0.7,*;q=0.7');
            $percentagem = $RESP[quantidade] / $_erb * 100;
            $ta = "";
            if($RESP[taRaiz] != ""){
       //// preciso recuperar esse valor que esta na celula e abrir em outra
       //// pagina para efetuar uma outra consulta, coloquei google, mas eu 
       //// criar uma outra pagina para receber
                $ta = "<td href=\"\" onClick=\"window.open('http://google.com','Janela','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=300,left=25,top=25'); return false;\">$RESP[taRaiz]</td>";
            }else{
                $ta = "<td class=\style3\></td>";
            }
            echo ("<tr>
                <td class=\style3\>$RESP[rota]</td>
                    $ta
                <td class=\style3\>$percentagem%</td>
                </tr>");
        }
        ?>
    
asked by anonymous 26.06.2018 / 18:51

1 answer

1

You can pass the value through Querystring, so just change where you have google.com and add the value to pass. For example

$ta = "<td href=\"\" onClick=\"window.open('http://google.com?taRaiz={$RESP[taRaiz]}','Janela','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=300,left=25,top=25'); return false;\">$RESP[taRaiz]</td>";

And on the other page, to search for it, you can use

<?php
$taRaiz = $_GET['taRaiz'];
// fazer o que precisas com esse valor
    
26.06.2018 / 18:57