In my PHP file, I have an echo statement, that outputs some HTML, within which i want to do some assignment based on onclick event.
echo "<td style='padding:10px; text-align:left;'> <a target='_blank' href='stat.php'  onclick='".  $_SESSION['dakno'] = $r[$j]; ."' >".$r[$j]."</a></td>";
I have tried a lot of combinations, but still getting syntax error because of the onclick section.
echo "<td style='padding:10px; text-align:left;'> <a target='_blank' href='stat.php'  onclick='"<?php  $_SESSION['dakno'] = $r[$j]; ?> "' >".$r[$j]."</a></td>";
EDITS:
I am an output field in a table to be a hyperlink. On clicking the link, the value of the clicked item is passed to another PHP file using a SESSION variable.
$sno = 1;
while($r = mysqli_fetch_array($rs)){
                            echo "<tr>";
                            echo "<td style='padding:10px; text-align:left;'>".$sno."</td>"; $sno++;
                            for( $j=1; $j<6; $j++){
                                if($j == 1){
                                echo "<td style='padding:10px; text-align:left;'> <a target='_blank' href='stat.php'  onclick='".  $_SESSION['dakno'] = $r[$j]; ."' >".$r[$j]."</a></td>";
                                continue;
                                }
                                else
                                echo "<td style='padding:10px; text-align:left;'>".$r[$j]."</td>";
                            }
                            echo "</tr>";
                }   
Please, help me to remove the syntax error I am making.
 
    