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 11 of 11
  1. #1
    VMM
    VMM is offline
    New Coder
    Join Date
    Jul 2005
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    printing data from db as a link

    Hello,

    I have asp program that reads information from the database and print the information to the table on a web page.

    The reading happens trough a normal "do while not EOF" loop.

    I have tried to make each data to a link. I mean that when the data is printed to the table, the program would also put a link to each data. When the user selects the link in the table, the program gets all of the information from the DB based on what link did the user pushed.

    For example: the program gets different car marks from the db and then prints them out into a table. every mark in the table is also a link. When the user selects, for example a Toyota, the web page gets all the toyotas from the db and prints them out.

    It feels like a simple problem but still I havent found a way to solve it. If somebody can give me a hint how I should proceed, please tell me.

    Thank you for advance.

  • #2
    New Coder
    Join Date
    Aug 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,

    try this:

    Code:
    <%
    carid = request.querystring("carid")
    carmark = request.querystring("carmark")
    If LEN(carid) > 0 Then
    select * FROM carlist where carid = '"& carid &"'"
    table for car-details......
    Else
    If LEN(carmark) > 0 Then
     select * FROM carlist where carid = '"& carid &"'"
    Else
     select * FROM carlist"
    End If
    %>
    <tr><th>Car</th><th>Mark</th></tr>
    <% Do While NOT RS.EOF %>
    <tr><td><a href="cars.asp?carid=<%= RS("carid") %>">Fiat Panda</a></td><td><a href="cars.asp?mark=<%= RS("carmark") %>">Fiat</a></td></tr>
    <% RS.Movenext
    Loop
    
    End If %>

  • #3
    VMM
    VMM is offline
    New Coder
    Join Date
    Jul 2005
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you Cyberlord. Your example was perfect. It worked very well.

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    And to open in a new window (if you ever want to do that) you could change this:

    <a href="cars.asp?carid=<%= RS("carid") %>"><%= RS("carname") %></a>

    To be more like this instead:

    <a href="cars.asp?carid=<%= RS("carid") %>" target="new"><%= RS("carname") %></a>
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

  • #5
    New Coder
    Join Date
    Aug 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can improve that:

    ... target="cars" onclick="window.open('','cars','menubar=no,scrollbars=yes,status=no,width=550,height=580,left='+ (screen.width-550)/2 +',top='+ (screen.height-580)/2 +'')">...

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,960
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Code:
    <a href="cars.asp?carid=<%= RS("carid") %>" target="cars" onclick="window.open(this.href,this.target,'menubar=no,scrollbars=yes,status=no,width=550,height=580,left='+ (screen.width-550)/2 +',top='+ (screen.height-580)/2 +'').focus();return false;">

  • #7
    New Coder
    Join Date
    Aug 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You dont need to specify the url again, because i have set the target by name (cars), but i think your code should also be okay.

    cheers

  • #8
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    Quote Originally Posted by Bullschmidt
    And to open in a new window (if you ever want to do that) you could change this:

    <a href="cars.asp?carid=<%= RS("carid") %>"><%= RS("carname") %></a>

    To be more like this instead:

    <a href="cars.asp?carid=<%= RS("carid") %>" target="new"><%= RS("carname") %></a>
    i thought tht was sposed to be target="_blank"

    if you want all links on a page to open in a new window u can also do <base target="_blank"> in the head section.. just thought id mention that since no1 ever uses <base> even though it can be prety useful

  • #9
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    i thought tht was sposed to be target="_blank"
    _blank is used a lot but a user-defined name is also allowed.

    Sometimes I like to use a different user-defined name so that it will be sure to open in a new window (so that the focus is sure to move to there) instead of one that has already been opened (just a matter of preference I suppose).

    And good point about base...
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

  • #10
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,960
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Quote Originally Posted by Bullschmidt
    Sometimes I like to use a different user-defined name so that it will be sure to open in a new window (so that the focus is sure to move to there)
    For user-defined window target name (and if the window with that name is already opened), focus is only set if you explicitly call the focus() method. Unlike in _blank where the focus is always set to the newly opened window even without calling focus() method.

  • #11
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Will have to play/test that a little - thanks for the info Glenn!
    Last edited by Bullschmidt; 08-23-2005 at 05:48 AM.
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips


  •  

    Posting Permissions

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