if(request.search1 || request.search2) {
dbconnect();
if(request.search1) {
//if they search using the textbox
contact = database.cursor("SELECT * FROM contacts WHERE lastname LIKE '%" + request.search1 + "%' ORDER BY firstname")
}
if(request.search2) {
if(request.search2 == "all") {
//Select all the contacts, no search criteria
contact = database.cursor("SELECT * FROM contacts ORDER BY lastname")
}
else {
//Select all contacts where the last name starts with the letter chosen.
var lowcaps = request.search2.toLowerCase()
contact = database.cursor("SELECT * FROM contacts WHERE lastname LIKE '" + request.search2 + "%' OR lastname LIKE '" + lowcaps + "%' ORDER BY firstname")
}
}
}
Last Name begins with:
if(request.search1) {
write("Contacts with the last name containing " + request.search1 + "")
}
if(request.search2) {
if(request.search2 == "all") {
write("List of All Contacts")
}
else {
write("Contacts whose Last Name begins with the letter " + request.search2 + "")
}
}
if(contact.next()) {
if(request.search1 || request.search2) {
write("
Select a contact name from the list, then choose a number of days within or enter a date range to view a report:")
write("