I was programming something in PHP but since I\'m a newbie I got stuck.
I have no clue how should I escape quotes on the following line. Moreover, I think the PHP tags i
I am boot sure what DoNav does but I think you want to have this line instead:
echo '<tr onclick="DoNav(\'list.php?id=' . $row['ID']. '\');">';
In PHP the \ is the escape character. If you want to escape a " you can write \"
I hope it was helpful. Good luck
The general/common escape character is \
, works in PHP and Javascript.
echo '<tr onclick="DoNav(\'list.php?id=' . $row['ID'] . '\');">';
Escape with a backslash, use "." for concatenation.
$row = array();
$row['ID'] = 1;
echo '<tr onclick="DoNav(\'list.php?id=' . $row['ID']. '\');">';
Output
<tr onclick="DoNav('list.php?id=1');">
Also make sure to escape any content you're going to use in Javascript or HTML. For an ID, you might just cast as an integer:
echo '<tr onclick="DoNav(\'list.php?id=' . (int)$row['ID']. '\');">';
Strings'll be more important to escape.
This u need
echo '<tr onclick="DoNav(\'list.php?id='.$row['ID'].'\');">';