# DREAMWEAVER 8 how to search between 2 dates



## htmlvisions (May 2, 2009)

I set up a data base for my carpet cleaning business and all is well until I try to set up a results page to find customers by searching between two dates. This is the only trouble I have and it has been very hard to find an answer. I am using Dreamweaver 8 to create the code for connections etc.. 

What I have is a form with two form fields. One is id="from" from date and the other is id="thru" which is to the last date in the search.

I don't think DW can do this but I know their has to be a work around. Any clues?

Thanks in advance.


----------



## Redcore (Aug 14, 2007)

Dreamweaver doesn't do database searches, does it? It's just a design program...you'd need to build some server-side script to search the database - like PHP.


----------



## htmlvisions (May 2, 2009)

No Dreamweaver dose not. However it helps me to ad all the little code snippets such as recordset info and the php code to do the search. I have the database running and created multiple search forms such as " search by first name " " search by last name " etc. they work perfectly and is formatted to display results exactly as I want. What I need is to be able to search between two dates entered in to different form fields. I do not necessarily need dreamweaver I just really need to know how to code or see an example of a full results page including php that dose this. 

I know how to use the 

SELECT * FROM colname >= 'var_from_field' AND colname <= 'var_to_field'

on the results page. the " 'vars' " are the id tags from the form fields on search form. 
What I can't figure out is how to capture both dates or " 'vars' " from the search page form. Dreamweaver 8 only sets the stage for single form field searches by default but I know there is a way around it and I am sure it is a no brainer but I am stuck.

The code is too complex for dreamweaver to create so it only fetches the first id. It is also using %s as the first variable and I think I have to some how define the second id but not sure how to do so.


----------



## htmlvisions (May 2, 2009)

Any ideas?


----------



## htmlvisions (May 2, 2009)

I have it working now. May not be completely secure but her it is. Of course I have changed connection name. Just insert yours.

This is the results page.

<?php require_once('Connections/YourConnectionName'); ?>
<?php


$FromDate=$_POST['FromDate'];
$ToDate=$_POST['ToDate'];

$results=mysql_query("select * from customers WHERE lastdate BETWEEN '".$FromDate."' AND '".$ToDate."' ORDER BY lastdate DESC");

?>




<div id="container">
<?php while($myinfo=mysql_fetch_array($results)) ** ?>
<table border="0" cellpadding="0" cellspacing="0">
<tr>

<td width="270" class="recordidresults-main">
ID: <?php echo ($myinfo['id']); ?></td>
</tr>
<tr>
<td class="results-main"><?php echo ($myinfo['name']); ?> <?php echo ($myinfo['lastname']); ?></td>
<td width="250" align="left" valign="top" class="recordidresults-main"><?php echo $myinfo['lastdate']; ?></td>
<td width="253" rowspan="5" align="left" valign="top" class="style14-main" style="border-right:none;"><?php echo $myinfo['details']; ?></td>
</tr>
<tr>
<td class="results-main"><?php echo $myinfo['address']; ?></td>
<td align="left" valign="top" class="recordidresults-main nextdate-main"><?php echo $myinfo['nextdate']; ?></td>
</tr>
<tr>
<td class="results-main"><?php echo $myinfo['city']; ?> <?php echo $myinfo['zip']; ?></td>
<td align="left" valign="top" class="recordidresults-main"><?php echo $myinfo['type']; ?></td>
</tr>
<tr>
<td class="results-main"><?php echo $myinfo['phone1']; ?><br /><?php echo $myinfo['phone2']; ?></td>
<td align="left" valign="top" class="recordidresults-main">$<?php echo $myinfo['amount']; ?></td>
</tr>
<tr>
<td class="results-main"> </td>
<td align="left" valign="top" class="style14-main"> </td>
</tr>
<tr>
<td height="2" colspan="4" align="left" valign="middle" bgcolor="#F4F4F4"></td>
</tr>
</table>
<?php } ?> 
</div>


----------



## tbarkdull (Feb 28, 2006)

Yes you can do it in Dreamweaver 8 and yes Dreamweaver does do database searches. I have a database in MS Access and setup a query in it to return all records with the fields I need. Then simply build the filter, well half of it, Dreamweaver like this

MMColParam is set to initial value 01/01/2000 and run-time value is Request.QueryString("dateof")

SELECT *
FROM qry_problem
WHERE dateofevent >= 'MMColParam' 

and add a second variable 'MMColParam2' 

MMColParam2 is set to initial value 01/02/2000 and run-time value is Request.QueryString("dateend") and change the code to read 

SELECT *
FROM qry_problem
WHERE dateofevent >= 'MMColParam' AND dateofevent <= 'MMColParam2'
ORDER BY dateofevent ASC

Then, since we are using dates, replace the single quotes with #

SELECT *
FROM qry_problem
WHERE dateofevent >= #MMColParam# AND dateofevent <= #MMColParam2#
ORDER BY dateofevent ASC

Now you can set in your form fields "dateof" and "dateend" (with inital value of 00/00/0000) on the form and submit!


----------



## dm01 (Oct 10, 2006)

tbarkdull

As evidenced by the last reply date of the thirty-first of May, this thread is no longer active. In the OP's profile, I can see that this user stopped coming to TSF in mid-June.

Usually, after one month's inactivity a thread can be judged inactive. People generally do not like people posting in threads that are inactive, as they find such actions annoying.

This thread is now closed to further replies.


----------

