|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
formatting data from DB using ASP
I'm trying to write a script using ASP that will take data from an Access database and generate the HTML table to hold the data and format the the data in the HTML table. I'm not having any problem retrieving the data, but I'm not very knowledgeable about generating the HTML using ASP.
I want to create one page with a list of links of different types of products and when you click on the link it will dynamically generate a page that will list the products for the category of the link. Can anyone point me to a tutorial that demonstrates how to do something similar? Thanks in advance. -Dman100- |
|
#2
|
|||
|
|||
|
Well the first step is getting the recordset with the data you want. You mention that this part is ok, you do not have any problem with that, is that correct ?
Now assuming your recordset object is objRst then just for testing purposes, try something like: <% If objRst.EOF Then Response.Write "No data inside the recordset, the SQL Query returned no data" Response.End 'or Response.Redirect "..." Else While NOT objRst.EOF Response.Write "-->" & objRst("Field1") & "<--<hr>" objRst.MoveNext Wend End If 'Free the object objRst.Close Set objRst = nothing 'Perhaps close and set to nothing the database connection %> 'NOTE Field1 is the name of one of the field you've requested when making/building your SQL Query Run that and see if it works, once done you can replace the: Response.Write "-->" & objRst("Field1") & "<--<hr>" with building the hyperlink dynamically such as: Response.Write "<a href=""products.asp?Id=" & objRst("ProductId") & """>" & objRst("Field2") & "</a>" NOTE: I've assumed you had a field called ProductId The idea is that this script creates an hyperlink that is set to the page products.asp it has a parameter in the QueryString named id= I then print the objRst("ProductId") When the user clicks the hyperlink, you'll something like: products.asp?id=3 Then in the products.asp page, you'll need to retrieve the value via the QueryString like this: ----------products.asp-------------- <% Dim lngProductId lngProductId = Trim(Request.QueryString("id")) 'FOR DEBUG ONLY 'Response.Write "ProductId: " & lngProductId & "<hr>" 'Response.End 'The you can build an SQL Query to obtain the products details for that given lngProductId variable %> Hope this helps! Sincerely Vlince |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > formatting data from DB using ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|