PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
cjkeane
Forum Contributor
Posts: 217 Joined: Fri Jun 11, 2010 1:17 pm
Post
by cjkeane » Fri May 13, 2011 9:37 am
i'm having a bit of trouble with this line of code. anyone have any ideas? i know its a matter of quotes in the right place.
Code: Select all
<?php
echo '<td><a href="sr_bytypedetails.php?TypeOfFile='.$result['TypeOfFile'].' onclick="toggle_visibility('details');" > '. $result['TypeOfFile'] .'</a></td>';
?>
Last edited by
cjkeane on Fri May 13, 2011 9:39 am, edited 1 time in total.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Fri May 13, 2011 9:39 am
If you want single quotes inside of single quotes, you need to escape them, or use double quotes.
Code: Select all
echo '<td><a href="sr_bytypedetails.php?TypeOfFile='.$result['TypeOfFile'].' onclick="toggle_visibility(\'foo\');" > '. $result['TypeOfFile'] .'</a></td>';
cjkeane
Forum Contributor
Posts: 217 Joined: Fri Jun 11, 2010 1:17 pm
Post
by cjkeane » Fri May 13, 2011 9:57 am
i've reworked it, and i still have an issue.
Code: Select all
<?php
echo '<td><a href="sr_bytype.php?TypeOfFile='.$result['TypeOfFile'] . ' onclick="document.getElementById('\foo\').style.display=(document.getElementById('\foo\').style.display=='\block\')?\'none\':'\block\';"> '. $result['TypeOfFile'] .'</a></td>';
?>
John Cartwright wrote: If you want single quotes inside of single quotes, you need to escape them, or use double quotes.
Code: Select all
echo '<td><a href="sr_bytypedetails.php?TypeOfFile='.$result['TypeOfFile'].' onclick="toggle_visibility(\'foo\');" > '. $result['TypeOfFile'] .'</a></td>';
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Fri May 13, 2011 10:10 am
Your last 'block' bit doesn't have the opening single quote escaped; the backslash is after the quote, not before it.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Fri May 13, 2011 10:11 am
Look carefully at the position of my escaping backslash, and the position of where you put the escaping backslash.
cjkeane
Forum Contributor
Posts: 217 Joined: Fri Jun 11, 2010 1:17 pm
Post
by cjkeane » Fri May 13, 2011 11:47 am
i see my problem. thanks! issue has been resolved!