Database text values will be displayed on HTML page and once the user clicks the paragraph JQuery an alert message will pop up with database values.
But the paragraph contains " and '. When passing article-data to JQuery it will pass text up to first ' in the paragraph. How to solve this without doing any change in MySQL database?
<?php
foreach ($data as $add) {
echo "<div>";
echo "<p class='target' article-data='$add->p_content' >" . $add->p_id . $add->p_content . "</p>";
echo "</div>";
}
?>
<script>
//Display dialog box when mouse click
$( ".target" ).click(function() {
alert($(this).attr("article-data"));
});
</script>
p_content).'" >' . $add->p_id . $add->p_content . '
';` – Wesley Smith Feb 11 '16 at 07:45