MySQL DB から結果をフィルタリングしようとしていますが、うまくいきません。
ユーザーはフォームに開始日と終了日を入力します (例: FROM 01/11/2013 TO 14/11/2013)
結果をフィルタリングするコードは次のとおりです。
$dbserver = "localhost";
$dbname = "nameofDB";
$dbusername = "username";
$dbpassword = "password";
$mysqli = new mysqli($dbserver, $dbusername, $dbpassword, $dbname);
$query = "SELECT * FROM transfer WHERE personID = 84587749 AND DATE(time) BETWEEN ? AND ?";
if($stmt = $mysqli->prepare($query)){
/*
Binds variables to prepared statement
i corresponding variable has type integer
d corresponding variable has type double
s corresponding variable has type string
b corresponding variable is a blob and will be sent in packets
*/
$to = $_POST['to'];
$from = $_POST['from'];
$stmt->bind_param('ss', $from, $to);
/* execute query */
$stmt->execute();
/* Get the result */
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
// Configure this how you want to print out each row.
echo 'Details: '.$row['details'].'<br>';
echo 'Time: '.$row['time'].'<br>';
echo 'Balance: '.$row['balance'].'<br>';
echo '<br><br>';
}
/* free results */
$stmt->free_result();
/* close statement */
$stmt->close();
}
/* close connection */
$mysqli->close();
これは結果を示していません。誰か助けてもらえますか?