Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help with Database/Forms

Status
Not open for further replies.

eyesrblu

Technical User
Jul 19, 2001
2
US
I hope I can explain this so you know what I am trying to do. I will lay out a short example.

Field 1 Field 2 Field 3 Field 4 Field 5
Clearwater 10 10C Clearwater Dayton
Ft. Lauderdale 20 10C Clearwater Dayton
Miami 30 30C Clearwater Dayton


Ok the above represents my database. I want users to be able to search the database for whatever criteria they want utilizing list boxes or something similar. For example, I want to be able to list all of the contents from Field 1 in a list box for the user to select from. When the user picks "Miami" he will get all of the information for Miami (fields 1-5). I also want it do be dynamic. If I add new cities to the database, I want it to update the form with these cities. Is that even possible?

Thanks
 
This is certainly possible, but you will need to use some server-side scripting (Perl, ASP, PHP etc)

Not sure how much code your after, so I'll just list some logic for starters.

"Dynamic" List, perform an SQL SELECT on the database,

IE for field1:
SELECT DISTINCT field1 FROM database_table ORDER BY field1

This selects all the unique values in field1, and sorts them into alphabetical order.

You then loop through the search results, and output them within a HTML SELECT
IE
<select name=&quot;field1&quot;>
{Code to loop through field1 results}
<option value=&quot;$field1&quot;>$field1</option>
{end of looping}
</select>

Similar sort of thing for the other &quot;Dynamic&quot; lists that you want...

If you require it, I can provide some sample code in Perl or ColdFusion (don't know ASP or PHP yet)...
 
Thanks for the reply. I was trying to stay away from Perl and ColdFusion for the simple reason that I have absolutely no clue. Since the database probably would not change frequently, would it be possible then to have a static list for the user to choose from and it go to the database and return the results in a format that I specify?

I am new to the whole database and front page working together scenario so please bear with me.

Thank you.
 
Yes this can be done with frontpage....It looks like you want a dropdown menu to populate the search field for a secondary search...for example with your data you would like a listing of thew cities then after you select a city get the tempuratures and stuff...

here you go...
First We have to start from the end and work forwards.
Create the table you want in the end in this table click the more options button during step # of the insert database results wizard. Click Criteria . Click add. In the filedname select the field you want...in your case &quot;City&quot;. click equals in the comparison and then again select your fieldname for the value field. Make sure the use this search form field is checked. &quot;OK&quot; out of the rest of the wizard....

You should now have a page with a form containing a text box plus reset and submit buttons, you also have a table below the form. Cut the form and paste it into a new blank page. this will be the page that sends the criteria to the results page.

On the page with the form, Click the text box and delete it. You are going to replace it with a drop down box generated by the insert database wizard. Click insert database results and select the table that you want to use as the drop down. In Step three of the wizard chose only the field that you are searching by in the results page...so again for you this is the field &quot;City&quot; . in step 4 of the wizard select &quot;Drop down list&quot; next out of the wizard.


This should make a drop down where the text box was...it should submit the result in your drop down to the second page....and that page should present your data in a table or however you formatted it...

save both pages with the extension .asp

One thing to know. Preview will not work with ASP and you have to have the pages saved on a Web server that can Do ASP...frontpage servers do and can...


hope this helps..

Tal McMahon


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top