内容可编辑字段在 PHP 中不起作用,但在 HTML 中起作用
好的,我知道在 HTML 中进行内联编辑的可编辑字段的代码。但我无法使用
我在 HTML 工作代码和 PHP 中附加的相同 PHP 代码,我缺少
请指导,
谢谢
HTML (WORKING)
<td style="text-align:center;" contenteditable="true" data-old_value="<?php echo $row1["view"];?>" onBlur="saveInlineEdit(this,'view','<?php echo $row1["id"]; ?>')" onClick="highlightEdit(this);"><?php echo $row1["view"]; ?></td>
PHP(肯定是我犯了一个错误 - 不工作)
echo "<td style='text-align:center;' contenteditable='true' data-old_value='<?php echo $row1["view"];?>' onBlur='saveInlineEdit(this,"view","<?php echo $row1["id"]; ?>")' onClick='highlightEdit(this);'><?php echo $row1["view"]; ?></td>
OK I know the code for editable field working in HTML, inline edit. But I am unable to use the same i PHP code
I am attaching below HTML working one and PHP in echo where I am lacking
Please Guide
Thanks
HTML (WORKING)
<td style="text-align:center;" contenteditable="true" data-old_value="<?php echo $row1["view"];?>" onBlur="saveInlineEdit(this,'view','<?php echo $row1["id"]; ?>')" onClick="highlightEdit(this);"><?php echo $row1["view"]; ?></td>
PHP (Surely there is a mistake by me - Not Working)
echo "<td style='text-align:center;' contenteditable='true' data-old_value='<?php echo $row1["view"];?>' onBlur='saveInlineEdit(this,"view","<?php echo $row1["id"]; ?>")' onClick='highlightEdit(this);'><?php echo $row1["view"]; ?></td>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅当您处于 HTML 输出模式并且需要返回 PHP 执行时才使用。但您已经在执行 PHP。它在字符串中没有做任何特殊的事情,只是按字面意思进行回显。
只需使用普通的变量替换或串联即可。
另外,您需要转义字符串内的文字
"
。<?php echo
is only used when you're in HTML output mode and need to get back into PHP execution. But you're already executing PHP. It doesn't do anything special inside a string, it's just echoed literally.Just use normal variable substitution or concatenation.
Also, you need to escape the literal
"
inside the string.我怀疑例外的答案是否有效,至少缺少一个“。我也更喜欢串联,因为它更具可读性。
连接:
你也可以通过输出缓冲来走肮脏的路:
I doubt that the excepted answer will work, atleast one " is missing. I also prefer concatenation, since it is better readable.
Concatenation:
you could also go the dirty way with output buffering: