I have a php variable ($num_rows) that i want to add t开发者_运维技巧o button value.
I am not getting value i want which should show like "Pending Friend Requests(0)"
I tried many different things but is not working. How can i write the code so that i get right value?
Here is the code:
$interactionBox= '<input type="button" value="Pending Friend Requests(\'.$num_rows.\')" onclick="return false" onmousedown="javascript:toggleInteractContainers(\'friend_requests\');"/>';
I tried:
value="Pending Friend Requests(".$num_rows.")"
value="Pending Friend Requests(.".$num_rows.".)"
You need to remove the backslashes before the single quotes for the variable to be included like so:
$interactionBox= '<input type="button" value="Pending Friend Requests('.$num_rows.')" onclick="return false" onmousedown="javascript:toggleInteractContainers(\'friend_requests\');"/>';
There's something wrong with your escaped '
around the values.
Do it this way: $variable = "parsed string, so the variable name can be inside the string $num_rows"; $variable = 'This is a static string so the variables have to be appended, e.g. ' . $num_rows . ', to work.';
Escaped quote characters (\"
or \'
) are treted as if they'd be any other standard character inside the string.
just try this one
value="Pending Friend Requests('.$num_rows.')"
no need to escape single quotes within double quotes
精彩评论