Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: Variable value is not showing

I am putting a html inside the php echo like .

echo '<td onclick="getdesc($descriptn)">';

My problem is onclick is not working i also tried like

echo '<td onclick="getdesc(\'$descriptn\')">';

But in this i am not geting the value of variable $descriptn is directly printing .

Please tell me what is the right way to do this ,

like image 816
masterofdestiny Avatar asked Feb 18 '23 03:02

masterofdestiny


2 Answers

Change to

echo '<td   style="margin-top: 3px; padding: 3px 2px; background: none repeat scroll 0px 0px #E9E9E9;" onclick="getdesc(\''.$descriptn.'\')" >';
like image 107
Dr. Dan Avatar answered Feb 21 '23 03:02

Dr. Dan


use double quote for this, that was the mistake.

echo "<td   style='margin-top: 3px; padding: 3px 2px; background: none repeat scroll 0px 0px #E9E9E9;' onclick='getdesc(\'$descriptn\')' >";
like image 28
Yogesh Suthar Avatar answered Feb 21 '23 02:02

Yogesh Suthar