0

ajax を介して 2 つの日付を mysql クエリに渡す必要があります。私は2つの日付入力を持っています。

これは、入力を持つ index.php です。

<div id="input">
<td><input type="date" name="date_start"></td>
<td><input type="date" name="date_end"></td>

<input type="button" class="button" value="Get Value">
</div>
<div id="count_display">
</div>

これは、作業クエリを含む getresult.php ファイルです

$date_start=$_GET['date_start'];
$date_end=$_GET['date_end'];

$select="select * from tblreport where (date(date_added) between '$date_start' AND '$date_end');";
$res = mysql_query($select);
$rec_count = mysql_num_rows($res);

echo "There are <font color='red' size='3'>".$rec_count."</font> matching records found.";

<div id="count_display">ページを更新/リロードせずにリアルタイムで結果を表示する ajax メソッドを使用して、index.php ファイル内の getresult.php からの結果のエコーを表示したいと考えています。

結果は、このページの例と非常によく似ています: http://www.w3schools.com/php/php_ajax_database.aspしかし、必要なのは、クエリによって返された行の数だけです。

4

2 に答える 2