[請益] 兩個按鈕但無法取值
我是個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
→
08/21 23:13, , 1F
08/21 23:13, 1F
→
08/22 02:16, , 2F
08/22 02:16, 2F
→
08/22 13:47, , 3F
08/22 13:47, 3F
→
08/22 14:23, , 4F
08/22 14:23, 4F
→
08/22 17:14, , 5F
08/22 17:14, 5F