我想将所有数据从给定值1输出到value2。我的代码正在运行,但它只显示一个数据。
<?php
mysql_connect("localhost","root","") or die("NO connection");
mysql_select_db("ci")or die("No DATABASE");
$value1 =$_POST['value1'];
$value2 =$_POST['value2'];
$output="";
if (isset($value1,$value2)){
$result=mysql_query("SELECT * FROM slogs WHERE stime BETWEEN
'". $value1 ."'AND '". $value2 ."' ");
$count=mysql_num_rows($result);
if($count==0){
$output='NO DATA IN DATABASE';
}
if ($count>1){
while($row=mysql_fetch_array($result))
{
$TIME=$row['stime'];
$DT=$row['DT'];
$FN=$row['FN'];
$LN=$row['LN'];
}
}
}
?>
答案 0 :(得分:0)
首先像这样更改您的查询
mysql_query("SELECT * FROM `slogs` WHERE stime BETWEEN
'". $value1 ."' AND '". $value2 ."'") or die(mysql_error());
然后尝试这种方式;在while
循环内,每当您将数据overriding
添加到相同的变量时
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
printf("Time: %s Date: %s FN: %s LN: %s", $row["stime"],$row["DT"],$row["FN"],$row["LN"]);
}`