Solution 1:
When passing a PHP string into an inline JavaScript function, you need to properly escape quotes:
echo "<td onclick='print_(\"" . $file[$i]->Name . "\");'>" . $file[$i]->Name . "</td>";
Explanation:
The outer HTML attribute uses single quotes (‘) for onclick.
The JavaScript string argument uses double quotes (“) to avoid conflicts.
Concatenate the PHP variable $file[$i]->Name inside the quotes.
Ensure $file[$i]->Name does not contain quotes, or escape them using addslashes():
$name = addslashes($file[$i]->Name);
echo "<td onclick='print_(\"$name\");'>$name</td>";
✅ This prevents syntax errors in the generated HTML/JavaScript.