PHP Concatenating in multiple quotes

I need to put $row['key'] in schedule.php?id= but I'm having trouble with concatenating

echo ' {label:"<a style=\'color:black\'target=\'_blank\' href=\'schedule.php?id='".$row['key']."' \'>'.$row['fname'].' '.$row['lname'].'</a>"},';


Don't build JSON by hand, create an array, then json_encode it. This should make it easier to juggle with your quotes.

$data = array(
    'label' => '<a style="color:black;" target="_blank" href="schedule.php?id='.$row['key'].'">'.$row['fname'].' '.$row['lname'].'</a>'
echo json_encode($data);

The syntax highlighter makes it easy to see your error. You just got your quotes backwards:

id='".$row['key']."' \'>'.$row['fname'].' '.$row['lname'].'</a>"},';
  ^^^^           ^^^^
  HERE           HERE

should be

echo ' {label:"<a style=\'color:black\'target=\'_blank\' href=\'schedule.php?id="'.$row['key'].'" \'>'.$row['fname'].' '.$row['lname'].'</a>"},';

As mentioned in the comments above, this is not the best way to construct JSON. Look into json_encode() to see how it can make your life easier.

Please use the following updated code :

echo " {label:'<a style=color:black target=_blank href=schedule.php?id=".$row['key'].">'".$row['fname']."' '".$row['lname']."'</a>'},";

Hope it helps you.

Need Your Help

what external content is accessed when visiting a page

firefox-addon loading external webpage statusbar

When we open a new webpage, usually some external content is loaded. Like Google Analysis, ads from third parties, as we see though the status bar (i.e. Reading

regular expression: search multiple words with multiple parts

python regex expression

I am trying to implement searching a set of multiple words which include multiple parts.