Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    why everything is on the same line

    I'm following an online example.
    I'm trying to put the results of a query on a table but everything appears on the same line..what's wrong with this code??

    <table border=1><tr><td><strong>Numero foto</strong></td><td><strong>Nome foto</strong></tr>
    <% While Not RS.EOF
    Response.Write("</td><td>")
    %><%=(RS.Fields.Item("FOTO_ID").Value)%><%
    Response.Write("</td><td>")
    %><%=(RS.Fields.Item("FOTO_Nome_foto").Value)%><%
    RS.Movenext
    Wend %>
    </td></tr></table>

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Try:
    Code:
    <table border=1><tr><td><strong>Numero foto</strong></td><td><strong>Nome foto</strong></tr>
    <% 
    While Not RS.EOF
    	Response.Write("<tr>")
    	Response.Write("<td>" & RS.Fields.Item("FOTO_ID").Value & "</td>")
    	Response.Write("<td>" & RS.Fields.Item("FOTO_Nome_foto").Value & "</td>")
    	Response.Write("</tr>")
    	RS.MoveNext
    Wend 
    %>
    </table>
    Good luck

  • #3
    Regular Coder
    Join Date
    May 2005
    Location
    Michigan, USA
    Posts
    566
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just a little edit...
    Quote Originally Posted by Brandoe85
    Try:
    Code:
    <table border=1><tr><td><strong>Numero foto</strong></td><td><strong>Nome foto</strong></tr>
    <% 
    While Not RS.EOF
    	Response.Write("<tr>"  & vbcrlf)
    	Response.Write("<td>" & RS.Fields.Item("FOTO_ID").Value & "</td>"  & vbcrlf)
    	Response.Write("<td>" & RS.Fields.Item("FOTO_Nome_foto").Value & "</td>"  & vbcrlf)
    	Response.Write("</tr>"  & vbcrlf)
    	RS.MoveNext
    Wend 
    %>
    </table>
    Actually I am feeling really nice today. So I will show you a good example of this

    Code:
    Dim SQL, ADO, RST
    	
    	SET ADO = Server.CreateObject("ADODB.Connection")
    	ADO.ConnectionString = "Your Connection String"
    	if ADO.State = 0 then ADO.Open	
    	
    	SQL = " Select FOTO_ID as 'Numero foto', FOTO_Nome_foto as 'Nome foto' From FOTO Where FOTO_ID = 3"
    	
    	
    	SET RST = Server.CreateObject("ADODB.Recordset")
    	RST.CursorLocation = 3
    	RST.Open SQL, ADO, 0, 1
    	Set RST.ActiveConnection = Nothing	
    	
    	If Not RST.EOF then
    		Response.Write("<table>" & vbcrlf)
    			Response.Write("<thead>" & vbcrlf)
    				Response.Write("<tr>" & vbcrlf)
    					For Each q in RST.Fields
    						Response.Write("<td>" & q.name & "</td>" & vbcrlf)
    					next
    				Response.Write("<tr>" & vbcrlf)
    			Response.Write("</thead>" & vbcrlf)
    			Response.Write("<tbody>" & vbcrlf)
    				RST.MoveFirst()
    				Do while Not RST.EOF
    					Response.Write("<tr>" & vbcrlf)
    					For Each q in RST.Fields
    						Response.Write("<td>" & q & "</td>" & vbcrlf)
    					next
    					Response.Write("<tr>" & vbcrlf)
    					RST.MoveNext()
    				Loop
    			Response.Write("</tbody>" & vbcrlf)
    		Response.Write("</table>" & vbcrlf)
    	end if
    Last edited by SpirtOfGrandeur; 08-10-2005 at 06:16 PM.
    Note: I do not test code. I just write it off the top of my head. There might be bugs in it! But if any thing I gave you the overall theory of what you need to accomplish. Also there are plenty of other ways to accomplish this same thing. I just gave one example of it. Other ways might be faster and more efficient.

  • #4
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks both,I need a guide to Asp and databases!!

  • #5
    Regular Coder
    Join Date
    Jun 2003
    Location
    Silicon Forest
    Posts
    155
    Thanks
    0
    Thanked 5 Times in 5 Posts
    ASP:
    www.w3schools.com/asp
    ASP Database Connections
    www.w3schools.com/ado
    Structured Query Language (SQL) for talking to DB's
    www.w3schools.com/sql

    Those should be a few good guides. If you need anything else, a good Google search would probably help.
    Whats the point of a signature?

  • #6
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks all from a desperate Italian girl

  • #7
    Regular Coder
    Join Date
    Sep 2004
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts
    @SpirtOfGrandeur,
    I've seen THeader and TBody tags before, but what purpose do they serve? I've never used them myself, but I've seen sites done by others that have.

    --Neo

  • #8
    Regular Coder
    Join Date
    May 2005
    Location
    Michigan, USA
    Posts
    566
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by neocool00
    @SpirtOfGrandeur,
    I've seen THeader and TBody tags before, but what purpose do they serve? I've never used them myself, but I've seen sites done by others that have.

    --Neo

    They are actually part of a poperly formatted table. And then after that they make JS easier to use on the table itself.
    Note: I do not test code. I just write it off the top of my head. There might be bugs in it! But if any thing I gave you the overall theory of what you need to accomplish. Also there are plenty of other ways to accomplish this same thing. I just gave one example of it. Other ways might be faster and more efficient.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •