-2

I have the following script who list some sql values in a table

while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC))  {

            $idOfUrl = $row['2'];

            echo("<tr onclick='window.location.href = \"


// how can i insert here a  php value ? --> $idOfUrl

                \"';>");
            echo("<td>");
            echo $row['1'];
            echo("</td>");
            echo ("</tr>"); 
            echo("</a>");
            }

I want to make the entire row clickable to a page with an ID whos from the SQL table.

Thank you in advance !

2 Answers2

0

you want to insert a PHP variable while you are in PHP. this is very simple:

while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC))  {

    $idOfUrl = $row['2'];

    echo("<tr onclick='window.location.href = ".$idOfUrl."';>");
    echo("<td>");
    echo $row['1'];
    echo("</td>");
    echo ("</tr>"); 
    echo("</a>");
}
kscherrer
  • 5,486
  • 2
  • 19
  • 59
0

try

echo("<tr onclick='window.location.href=".$idOfUrl."';>");

or

echo("<tr onclick='window.location.href=\"$idOfUrl\"';>");

maybe thats hope you