Does anyone know if this is possible?
I have a javascript which highlights the table row when a user hovers down it. it now also links to a page when you click it. but i want to add php to my link. Can it be done?
I have attempted it myself but it gives me this error: Parse error: syntax error, unexpected '"', expecting T_STRING
<script>
$(function() {
$('tr').hover(function() {
$(this).css('background-color', '#eee');
$(this).contents('td').css({'border': '0px solid red', 'border-left': 'none', 'border-right': 'none'});
$(this).contents('td:first').css('border-left', '0px solid red');
$(this).contents('td:last').css('border-right', '0px solid red');
},
function() {
$(this).css('background-color', '#FFFFFF');
$(this).contents('td').css('border', 'none');
$('tr').click(function() {
document.location = <?php \"read_message.php?msg={$inbox[0]}\">{$inbox['subject']}"; ?>';
} );
});
});
</script>
3 Answers 3
You are getting parser error because $inbox['subject'] may contain some apostrophe's that are breaking the string opening and closing apostrophes.
Try using the below:
document.location = "<?php echo "read_message.php?msg={$inbox[0]}>{$inbox['subject']}" ?>";
1 Comment
try
document.location = <?php echo '"read_message.php?msg='.$inbox[0].'">'.$inbox['subject'] ; ?>
or
document.location = "read_message.php?msg=<?php echo $inbox[0]; ?>"><?php echo $inbox['subject'].'"'; ?>';
1 Comment
' at the enddocument.location = '<?php echo \"read_message.php?msg={$inbox[0]}\">{$inbox['subject']}"; ?>';
<?phpadd a'you aren't opening it. but you are also closing something else after['subject']}"with a"