我想在数据库中显示一个段落到表格单元格中.
结果是一条很大的1行,忽略了它在数据库中的组织方式.忽略'进入'例如(新线)
我想根据它在数据库中的编写方式准确地显示它.
例如,如果段落保存如下:
hello ,
my name is x.
Run Code Online (Sandbox Code Playgroud)
我希望它显示的确如此,而不是:
hello, myname is x.
Run Code Online (Sandbox Code Playgroud) 好吧,所以我要做的是触发PHP代码,只有当if条件为真时(在javascript中),我才明白php是服务器端,而javascript是客户端.除了1件事之外,php代码的包含工作完美,它实际上是在页面加载时触发,而不是在if条件发生时触发.如果你能帮我怎么做,我们将非常感激.我想只在if条件为真时才包含php文件
提前致谢
这是我正在使用的代码:
<html>
<script src="//cdnjs.cloudflare.com/ajax/libs/visibility.js/0.5/visibility.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script>
var seconds=20;
var flag=false;
$(document).ready(function(){
if (!flag)
Visibility.every(1000, tick);
function tick()
{
display();
if (seconds>0)
{
seconds--;
}
else
{
if (!flag){
document.getElementById('more').innerHTML +="<?php include_once('Code.php');
?>";
document.getElementById('more').style.visibility='visible';
flag=true;
}
}
}
function display()
{
$("#timer").html(seconds);
}
});
</script>
<div id="TrafficHeader" style="height:100px; background-color:grey; padding:20px;">
<div id="timer"></div>
<div id="more" style="visibility: hidden;"><a href="http://www.double-it.com/Traffic/index.php">View Next Ad</a></div></div>
<iframe id="myframe" src="<?php echo ''.$URL;?>" height="100%" width="100%" frameborder="0">
</iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 好吧,我在解决这个问题时遇到了麻烦,我是一名 php / C# Web 开发人员,并且没有 Javascript 的经验或知识,我必须做这一件需要 Javascript 的事情:
当加载某个页面时,计数器就会启动。客户必须在此页面停留 20 秒。之后,我想执行php代码。
因此,有两个问题与我有关,第一:如果客户端离开页面(意味着页面没有焦点),我如何停止计数器。
2)如何在javascript中执行php?,或者从 Javascript 调用 php 函数。
到目前为止我的代码是这样的:
<html>
<head>
</head>
<body>
<div id='timer'>
<script type="text/javascript">
COUNTER_START = 20
function tick () {
if (document.getElementById ('counter').firstChild.data > 0) {
document.getElementById ('counter').firstChild.data = document.getElementById ('counter').firstChild.data - 1
setTimeout ('tick()', 1000)
} else {
document.getElementById ('counter').firstChild.data = 'done'
}
}
if (document.getElementById) onload = function () {
var t = document.createTextNode (COUNTER_START)
var p = document.createElement ('P')
p.appendChild (t)
p.setAttribute …Run Code Online (Sandbox Code Playgroud)