Jump to content

from DB to ASP


kastellu
 Share

Recommended Posts

Hello,How i could create export from DB on html (asp) that would look like this.DB table tblItem looks like this:ItemID Item subItem--------------------------------1 ItemA sub12 ItemA sub23 ItemA sub34 ItemB sub45 ItemB sub56 ItemB sub6...What i would like is this kind of exported data in html table:ItemA: -sub1<blank space> -sub2<blank space> -sub3ItemB: -sub4<blank space> -sub5 <blank space> -sub6But now i get:ItemA: -sub1ItemA: -sub2ItemA: -sub3Thank you for help!kastellu

Link to comment
Share on other sites

O.K. I am trying to do this kind of example: http://www.w3schools.com/ado/showasp.asp?f...me=demo_query_4What i would need to change that i would see all the entrys from db without of chosing from select box and if there would be more than on entry at country, the name of country in table would be written only once at the topest field spain:xcvUSA:abdand not,spain: xspain: cspain: vUSA: aUSA: bUSA: dthank youkastellu

Link to comment
Share on other sites

If you were to do it in a form/select you could have used optgroup:

<select>    <optgroup label="Spain">HELLO    <option>x</option>    <option>y</option>    <option>z</option>    </optgroup></select>

The way you want to do it, you could specify ITEM as a variable and make it empty before you go into your loop. Then upon each loop check the past value against the current one. If it's different then write it out to the screen.something like:<%item=""while not YourRecordsetRS.eof if item<>YourRecordsetRS("item") then%> <td><%=YourRecordsetRS("item")%> </td> <%else%> <td> </td> <% item = YourRecordsetRS("item") YourRecordsetRS.movenextwEnd%>Just an idea. Any use?

Link to comment
Share on other sites

Hello I inserted your code, but i am not any good in programing, can you check it, where i did a mistake, please.<html><body><%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("_DB/baza.mdb"))set rs=Server.CreateObject("ADODB.recordset")sql="SELECT DISTINCT NazivSkupine FROM tblStoritve ORDER BY NazivSkupine"rs.Open sql,connNazivSkupine=request.form("NazivSkupine")%><form method="post">Izberi NAzivSkupine <select name="NazivSkupine"><% do until rs.EOF response.write("<option") if rs.fields("NazivSkupine")=NazivSkupine then response.write(" selected") end if response.write(">") response.write(rs.fields("NazivSkupine")) rs.MoveNextlooprs.Closeset rs=Nothing %></select><input type="submit" value="Potrdi"></form><%if NazivSkupine<>"" then sql="SELECT NazivSkupine,NazivPodskupine FROM tblStoritve WHERE NazivSkupine='" & NazivSkupine & "'" set rs=Server.CreateObject("ADODB.Recordset") rs.Open sql,conn%> <table width="100%" cellspacing="0" cellpadding="2" border="1"> <tr> <th>NazivPodskupine</th> <th><!--I think that it should be here instead of previous field NazivSkupine ( NazivSkupine is field that i am trying to get only once --><%NazivSkupine=""while not YourRecordsetRS.eofif NazivSkupine<>YourRecordsetRS("NazivSkupine") then%><td><%=YourRecordsetRS("NazivSkupine")%> </td><%else%><td> </td><%NazivSkupine = YourRecordsetRS("NazivSkupine")YourRecordsetRS.movenextEnd%></th> </tr><%do until rs.EOF response.write("<tr>") response.write("<td>" & rs.fields("NazivPodskupine") & "</td>") response.write("<td>" & rs.fields("NazivSkupine") & "</td>") response.write("</tr>") rs.MoveNextlooprs.closeconn.Closeset rs=Nothingset conn=Nothing%></table><% end if %></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...