Inside a php file i construct a table that i then echo and it shows the results of a query. One of the columns contains cells where i have an image. What i want to do is 1)when i hover over the image to see the string stored in the variable and 2)when i click on the image to see the same string in an alert box.
My code for that is the following
echo "<td href='#' onClick=alert('".$ResultTable[$i]."'); style='text-align: center;'><img src='IconImage.png' width='50' height='50' title='".$ResultTable[$i]."'/></td>";
Notes varchar(255) DEFAULT '---',
mysqli_query($con,"SET NAMES 'utf8'");
mysqli_query($con,"SET CHARACTER SET 'utf8'");
You need to wrap your onclick element inside a string, since you are manually outputting this you'll need to use the backslash to cancel it.
Or you can do this much more readable example:
Using the shorthand PHP will basically output the result of whats between the delimiters meaning you do not need to add