如何传递Now()函数从一个页面到另一个在php


How to pass the Now() Function from one page to another in php

timestamp=now()从一个页面显示到另一个页面。我怎么传递这个函数?与第二页一样,我想在timestamp=now()的基础上检索表。我试过了,但没有用。请你帮帮我。

编码
<script type="text/javascript" charset="utf-8">
function showCustomer(n)
{
var xmlhttp;    
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("display").innerHTML=xmlhttp.responseText;
    }
  }
  alert(n);
xmlhttp.open("POST","display.php?id="+ n,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
<?php $s= 'now()';
echo $s; ?>
<input type="button" value="h" name="s" onclick="showCustomer(<?php $s ?>)">
<div id='display' >
<?php 
echo "111";
?>
</div>

我通过以下代码从数据库检索数据:

<?php
include('config.php');
$sa="select * from table1 where timestamp=now()";
$result=mysql_query($sa) or die(mysql_error());
echo "<table border='1'>
<tr>
</tr>";?>
<?php
while($row = mysql_fetch_array($result)) 
{ 
    $row['c1'];
    $row['c2'];
    $row['c3'];
         $row['c4'];
}

我必须通过考虑Now()函数在下一页的按钮单击上调用此表。

假设您的目标是保留一些时间戳:使用会话

session_start();//in every file (in which you want to access sessions) as first statement before any output
//set time
$_SESSION['now'] = date("Y-m-d H:i:s"); //mysql datetime format
//read time
$save_time = $_SESSION['now'];

我想你漏掉了echo, <input type="button" value="h" name="s" onclick="showCustomer(<?php $s ?>)">

请!用<input type="button" value="h" name="s" onclick="showCustomer(<?php echo $s ?>)">

覆盖这一行

没有php NOW()函数它是一个mysql函数,如果你想要相同的值,mysql的NOW()返回

必须使用php的date("Y-m-d H:i:s");格式这是参考日期

<?php $s= date("Y-m-d H:i:s");
echo $s; ?>