| Display Part of Database Field ASP Script - ASP Web Pro |
|
ASP ScriptsDISPLAY PART OF DATABASE FIELDThere are times when you may only need to display part of the data from a complex database field on your web page. For example, you may have a Location field that contains the city where your office is located and also the driving directions to your office. Normally, these data types will be separated by a comma, colon, or something similar. So how do you separate this data on the web? The first thing you need to do is create a database called
MyDatabase. Then create a table called tblLocations with these
fields: Then, start adding a new record and enter "Miami : Take a left on Harris Street, right on Morgan Avenue, and we are the third building on the left". Enter some more records in the same fashion if you like. Next, you create a page called displaypartoffield.asp and copy the below code into your page:
This script will return all of the records in your database and will display only the data to the left of the ":" in your Location field. If you want to display only the data to the right of the ":" , substitute the below code for the above.
That's it, happy displaying!
|
||||
|
Main Menu Other Resources
Last Updated:
|
||||
|
© 1997-2010 ASP Web Pro, Inc. | Terms of Use
|