there are several things that you will have to use to make this work
- a loop to get each record out of the database
- an action script for the form.
once you design your form you'll have to point it towards another script, or itself to process the form.
<form name="getdates" method="post" action="do_getdates.php">
you would then house your database script in that file.
which might look something like this.
//connect to the database
include 'connect.php';
//get the dates from the form
$date1 = $_POST['date1']; //these two are extracting the information from the form
$date2 = $_POST{'date2'];
//in your code you used $date1 = date(d,m,y) this was pulling the date from the server not the form.
//this next part is tricky because we have to format the date correctly for extraction from
//the database. I am assuming the data is being collected like this
//$date1 = 06/10/2006
//and that your database is housing the information like this
// 2006-10-06
//unless you collect the date in the form the exact same way you have it housed in database
//you will have to pull it apart and piece it back together again
$date1 = explode("/",$date1); //this will split the variable inside the explode into an array using a / as the break point.
//this is a numbered array and starts with 0, so your date would be come day=0 month =1 year = 2
$date2 = explode("/",$date2);
//now we have to put them back together the right way for searching.
$date1 = "$date1['2']-$date1['1']-$date1['0']"; //this will now format the date in 2006-10-06 format
$date2 = "$date2['2']-$date2['1']-$date2['0']";
//now you'll have to search the database for entries that are => date1 and <= date2
$sql = "SELECT * FROM calls WHERE date => '$date1' AND <='$date2'";
$pull_dates = mysql_query($sql);
//once you are pulling the correct information you will have to loop it to get all the
//dates from the database.
while($r = mysql_fetch_array($pull_dates)){
//now you can extract and echo the information from the database.
//we will assume your database names
$call_title = $r['fieldname']; //replace fieldname with the name from your database
$call_desc= $r['fieldname2'];
then echo them and any other information you might want.
echo $call_title;
echo '<BR>';
echo $call_description
}//close the loop
that should do it.
there maybe a bug or two in the script as i didn't test it thoughly, but the theory is sound, i use it all the time.
i hope i did a good job explaining it.
anyone else who reads this feel free to make corrections / revisions.
chris