作者beavis1103 (晚九朝五)
看板PHP
标题[请益] 两个按钮但无法取值
时间Sat Aug 21 23:01:39 2010
我是个php的初学者~以下是我的程式码~
<html>
<head>
<title>Collect training data</title>
</head>
<body>
Input location:
<form action="collect_training_data.php" method="post">
<input type="text" name="input" size="10">
<input type="submit" name="start" value="Start" size="5">
<input type="submit" name="stop" value="Stop" size="5">
</form>
<br><a href='collect_training_data.php'>Redo</a><br>
</body>
</html>
(以下是php的部份)
<?php
$sql_time="select now() as timestamp";
if($_POST['start'] && $input_location!=""){
echo "start to collect training data which location is : ".$input_location;
$result=@mysql_query($sql_time);
$time_begin= mysql_fetch_array($result);
echo "<br>begin time : ".$time_begin['timestamp'];
}
if($_POST['stop']){
$result=@mysql_query($sql_time);
$time_end= mysql_fetch_array($result);
echo "<br>end time: ".$time_end['timestamp'];
echo "<br> Time between {$time_begin['timestamp']} and {$time_end['timestamp']};
}
?>
我的疑问是 按下start按钮再按下stop按钮後只会显示 $time_end['timestamp']的时间
究竟是哪边的问题呢??
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 219.85.98.17
1F:→ knives:这很正常阿,没有显示$time_end['timestamp']才不正常 08/21 23:13
2F:→ ileadu:begin的时间 早就被洗掉了.. 08/22 02:16
3F:→ beavis1103:那请问应该怎麽改才能两个时间都显示 08/22 13:47
4F:→ knives:从一开始你的设计观念就错了,无关php阿 08/22 14:23
5F:→ beavis1103:原来如此 我後来改用session就可以了 谢谢k大 08/22 17:14