Building a link out of a field value

Discussion in 'ASP General' started by Drew, Nov 3, 2004.

  1. Drew

    Drew Guest

    I would like to explore some different ways to build a link out of the
    following string from a db,

    Fiscal; swvtc/fiscal/fiscaldata.asp: Records; swvtc/records/recordsdata.asp:

    Which is just a string that has the link name, then the link target. So I
    would need to programmatically build a link from this field. I have found
    some other ways around this, but they involve Regular Expressions in
    vbscript and I was wondering if there was a more efficient way of doing
    this. My database table looks like this,

    Username - the username of the user
    Userlinks - the links as above, Fiscal; swvtc/fiscal/fiscaldata.asp:
    Records; swvtc/records/recordsdata.asp:

    I am open to any sort of delimeter instead of the : and ;.

    This will be used for an Intranet front page and would allow the users to
    have "quick links" on the front page.

    Thanks,
    Drew Laing
    Drew, Nov 3, 2004
    #1
    1. Advertising

  2. Drew

    Jeff Dillon Guest

    I would recommend not putting several types of information in one field.
    Add a Fiscal field and a Records field..then you don't need to parse at all.

    If you insist however, look at Instr

    Jeff
    "Drew" <> wrote in message
    news:...
    > I would like to explore some different ways to build a link out of the
    > following string from a db,
    >
    > Fiscal; swvtc/fiscal/fiscaldata.asp: Records;

    swvtc/records/recordsdata.asp:
    >
    > Which is just a string that has the link name, then the link target. So I
    > would need to programmatically build a link from this field. I have found
    > some other ways around this, but they involve Regular Expressions in
    > vbscript and I was wondering if there was a more efficient way of doing
    > this. My database table looks like this,
    >
    > Username - the username of the user
    > Userlinks - the links as above, Fiscal; swvtc/fiscal/fiscaldata.asp:
    > Records; swvtc/records/recordsdata.asp:
    >
    > I am open to any sort of delimeter instead of the : and ;.
    >
    > This will be used for an Intranet front page and would allow the users to
    > have "quick links" on the front page.
    >
    > Thanks,
    > Drew Laing
    >
    >
    Jeff Dillon, Nov 3, 2004
    #2
    1. Advertising

  3. That is an interesting method of storing data you have there... If this is
    how your data is, and assuming you cannot do anything about that, you can
    do:

    Dim sLinks, aLinks, aLink, sLinkTitle, sHref
    Dim i

    sLinks = yourRecordset.Fields.Item("Userlinks").Value
    aLinks = Split(sLinks, ":")
    For i = 0 To UBound(aLinks)
    aLink = Split(aLinks(i), ";")
    If UBound(aLink) = 1 Then
    sLinkTitle = Trim(aLink(0))
    sHref = Trim(aLink(1))
    Response.Write "<a href=""" & sHref & """>" & sLinkTitle & "</a><br>"
    End If
    Next


    Ray at work





    "Drew" <> wrote in message
    news:...
    >I would like to explore some different ways to build a link out of the
    >following string from a db,
    >
    > Fiscal; swvtc/fiscal/fiscaldata.asp: Records;
    > swvtc/records/recordsdata.asp:
    >
    > Which is just a string that has the link name, then the link target. So I
    > would need to programmatically build a link from this field. I have found
    > some other ways around this, but they involve Regular Expressions in
    > vbscript and I was wondering if there was a more efficient way of doing
    > this. My database table looks like this,
    >
    > Username - the username of the user
    > Userlinks - the links as above, Fiscal; swvtc/fiscal/fiscaldata.asp:
    > Records; swvtc/records/recordsdata.asp:
    >
    > I am open to any sort of delimeter instead of the : and ;.
    >
    > This will be used for an Intranet front page and would allow the users to
    > have "quick links" on the front page.
    >
    > Thanks,
    > Drew Laing
    >
    Ray Costanzo [MVP], Nov 3, 2004
    #3
  4. Drew

    Drew Guest

    Well, I want to lump it all in one field, like this,

    Fiscal; swvtc/fiscal/fiscaldata.asp: Records; swvtc/records/recordsdata.asp:
    Blah; swvtc/blah/blah.asp: Double Blah; swvtc/blahblah/blah.asp

    So that I don't have to have seperate fields for all of this... This is an
    intranet, so swvtc/records/recordsdata.asp is the actual link. I just need
    to make links like so,

    <a href="swvtc/records/recordsdata.asp">Records</a>

    In otherwords, the name of the link is the first entry followed by a ; and
    then the actual link is after that.

    Hope I've made myself more clear!

    Thanks,
    Drew




    "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
    news:%...
    > huh? Lost me there.
    > You want http://site/swvtc/fiscal/fiscaldata.asp generated from a db
    > entry? or you want to pass a value?
    >
    > basically just a simple Response.Write of an HREF will do what you need,
    > just put in within the DB lookup/read loop.
    >
    > --
    > Curt Christianson
    > Owner/Lead Developer, DF-Software
    > Site: http://www.Darkfalz.com
    > Blog: http://blog.Darkfalz.com
    >
    >
    > "Drew" <> wrote in message
    > news:...
    >>I would like to explore some different ways to build a link out of the
    >>following string from a db,
    >>
    >> Fiscal; swvtc/fiscal/fiscaldata.asp: Records;
    >> swvtc/records/recordsdata.asp:
    >>
    >> Which is just a string that has the link name, then the link target. So
    >> I would need to programmatically build a link from this field. I have
    >> found some other ways around this, but they involve Regular Expressions
    >> in vbscript and I was wondering if there was a more efficient way of
    >> doing this. My database table looks like this,
    >>
    >> Username - the username of the user
    >> Userlinks - the links as above, Fiscal; swvtc/fiscal/fiscaldata.asp:
    >> Records; swvtc/records/recordsdata.asp:
    >>
    >> I am open to any sort of delimeter instead of the : and ;.
    >>
    >> This will be used for an Intranet front page and would allow the users to
    >> have "quick links" on the front page.
    >>
    >> Thanks,
    >> Drew Laing
    >>

    >
    >
    Drew, Nov 3, 2004
    #4
  5. Drew

    Drew Guest

    Well that isn't how the data has to be, I just wanted users to be able to
    have as many links as they wanted, and I didn't know of a structure that
    could do that.

    I guess I could use something like this,

    Username
    UserLink1
    UserLink2
    UserLink3
    UserLink4
    UserLink5
    UserLink6
    UserLink7
    UserLink8
    UserLink9
    UserLink10

    Would that be a better structure?

    Thanks,
    Drew

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:...
    > That is an interesting method of storing data you have there... If this
    > is how your data is, and assuming you cannot do anything about that, you
    > can do:
    >
    > Dim sLinks, aLinks, aLink, sLinkTitle, sHref
    > Dim i
    >
    > sLinks = yourRecordset.Fields.Item("Userlinks").Value
    > aLinks = Split(sLinks, ":")
    > For i = 0 To UBound(aLinks)
    > aLink = Split(aLinks(i), ";")
    > If UBound(aLink) = 1 Then
    > sLinkTitle = Trim(aLink(0))
    > sHref = Trim(aLink(1))
    > Response.Write "<a href=""" & sHref & """>" & sLinkTitle & "</a><br>"
    > End If
    > Next
    >
    >
    > Ray at work
    >
    >
    >
    >
    >
    > "Drew" <> wrote in message
    > news:...
    >>I would like to explore some different ways to build a link out of the
    >>following string from a db,
    >>
    >> Fiscal; swvtc/fiscal/fiscaldata.asp: Records;
    >> swvtc/records/recordsdata.asp:
    >>
    >> Which is just a string that has the link name, then the link target. So
    >> I would need to programmatically build a link from this field. I have
    >> found some other ways around this, but they involve Regular Expressions
    >> in vbscript and I was wondering if there was a more efficient way of
    >> doing this. My database table looks like this,
    >>
    >> Username - the username of the user
    >> Userlinks - the links as above, Fiscal; swvtc/fiscal/fiscaldata.asp:
    >> Records; swvtc/records/recordsdata.asp:
    >>
    >> I am open to any sort of delimeter instead of the : and ;.
    >>
    >> This will be used for an Intranet front page and would allow the users to
    >> have "quick links" on the front page.
    >>
    >> Thanks,
    >> Drew Laing
    >>

    >
    >
    Drew, Nov 4, 2004
    #5
  6. NO, this would be a terrible design! You waste 10 columns on the user who
    doesn't want any links, 9 columns on the user who only wants one, and you
    don't have enough for the user who wants 11 (or 111).

    CREATE TABLE dbo.Users
    (
    UserID INT IDENTITY(1,1) PRIMARY KEY,
    Username VARCHAR(32) NOT NULL UNIQUE
    )

    CREATE TABLE dbo.UserLinks
    (
    UserID INT NOT NULL
    FOREIGN KEY REFERENCES dbo.Users(UserID),
    Link VARCHAR(32)
    )

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "Drew" <> wrote in message
    news:...
    > Well that isn't how the data has to be, I just wanted users to be able to
    > have as many links as they wanted, and I didn't know of a structure that
    > could do that.
    >
    > I guess I could use something like this,
    >
    > Username
    > UserLink1
    > UserLink2
    > UserLink3
    > UserLink4
    > UserLink5
    > UserLink6
    > UserLink7
    > UserLink8
    > UserLink9
    > UserLink10
    >
    > Would that be a better structure?
    >
    > Thanks,
    > Drew
    >
    > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    > message news:...
    > > That is an interesting method of storing data you have there... If this
    > > is how your data is, and assuming you cannot do anything about that, you
    > > can do:
    > >
    > > Dim sLinks, aLinks, aLink, sLinkTitle, sHref
    > > Dim i
    > >
    > > sLinks = yourRecordset.Fields.Item("Userlinks").Value
    > > aLinks = Split(sLinks, ":")
    > > For i = 0 To UBound(aLinks)
    > > aLink = Split(aLinks(i), ";")
    > > If UBound(aLink) = 1 Then
    > > sLinkTitle = Trim(aLink(0))
    > > sHref = Trim(aLink(1))
    > > Response.Write "<a href=""" & sHref & """>" & sLinkTitle &

    "</a><br>"
    > > End If
    > > Next
    > >
    > >
    > > Ray at work
    > >
    > >
    > >
    > >
    > >
    > > "Drew" <> wrote in message
    > > news:...
    > >>I would like to explore some different ways to build a link out of the
    > >>following string from a db,
    > >>
    > >> Fiscal; swvtc/fiscal/fiscaldata.asp: Records;
    > >> swvtc/records/recordsdata.asp:
    > >>
    > >> Which is just a string that has the link name, then the link target.

    So
    > >> I would need to programmatically build a link from this field. I have
    > >> found some other ways around this, but they involve Regular Expressions
    > >> in vbscript and I was wondering if there was a more efficient way of
    > >> doing this. My database table looks like this,
    > >>
    > >> Username - the username of the user
    > >> Userlinks - the links as above, Fiscal; swvtc/fiscal/fiscaldata.asp:
    > >> Records; swvtc/records/recordsdata.asp:
    > >>
    > >> I am open to any sort of delimeter instead of the : and ;.
    > >>
    > >> This will be used for an Intranet front page and would allow the users

    to
    > >> have "quick links" on the front page.
    > >>
    > >> Thanks,
    > >> Drew Laing
    > >>

    > >
    > >

    >
    >
    Aaron [SQL Server MVP], Nov 4, 2004
    #6
  7. Drew

    Drew Guest

    That's what I thought, but I hadn't thought about your design...

    How can I make an insert page that has checkboxes that the users check which
    links they want and then it inserts a new record for each item checked? I
    don't think that I have ever done this.

    Thanks!
    Drew

    "Aaron [SQL Server MVP]" <> wrote in message
    news:...
    > NO, this would be a terrible design! You waste 10 columns on the user who
    > doesn't want any links, 9 columns on the user who only wants one, and you
    > don't have enough for the user who wants 11 (or 111).
    >
    > CREATE TABLE dbo.Users
    > (
    > UserID INT IDENTITY(1,1) PRIMARY KEY,
    > Username VARCHAR(32) NOT NULL UNIQUE
    > )
    >
    > CREATE TABLE dbo.UserLinks
    > (
    > UserID INT NOT NULL
    > FOREIGN KEY REFERENCES dbo.Users(UserID),
    > Link VARCHAR(32)
    > )
    >
    > --
    > http://www.aspfaq.com/
    > (Reverse address to reply.)
    >
    >
    >
    >
    > "Drew" <> wrote in message
    > news:...
    >> Well that isn't how the data has to be, I just wanted users to be able to
    >> have as many links as they wanted, and I didn't know of a structure that
    >> could do that.
    >>
    >> I guess I could use something like this,
    >>
    >> Username
    >> UserLink1
    >> UserLink2
    >> UserLink3
    >> UserLink4
    >> UserLink5
    >> UserLink6
    >> UserLink7
    >> UserLink8
    >> UserLink9
    >> UserLink10
    >>
    >> Would that be a better structure?
    >>
    >> Thanks,
    >> Drew
    >>
    >> "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    >> message news:...
    >> > That is an interesting method of storing data you have there... If
    >> > this
    >> > is how your data is, and assuming you cannot do anything about that,
    >> > you
    >> > can do:
    >> >
    >> > Dim sLinks, aLinks, aLink, sLinkTitle, sHref
    >> > Dim i
    >> >
    >> > sLinks = yourRecordset.Fields.Item("Userlinks").Value
    >> > aLinks = Split(sLinks, ":")
    >> > For i = 0 To UBound(aLinks)
    >> > aLink = Split(aLinks(i), ";")
    >> > If UBound(aLink) = 1 Then
    >> > sLinkTitle = Trim(aLink(0))
    >> > sHref = Trim(aLink(1))
    >> > Response.Write "<a href=""" & sHref & """>" & sLinkTitle &

    > "</a><br>"
    >> > End If
    >> > Next
    >> >
    >> >
    >> > Ray at work
    >> >
    >> >
    >> >
    >> >
    >> >
    >> > "Drew" <> wrote in message
    >> > news:...
    >> >>I would like to explore some different ways to build a link out of the
    >> >>following string from a db,
    >> >>
    >> >> Fiscal; swvtc/fiscal/fiscaldata.asp: Records;
    >> >> swvtc/records/recordsdata.asp:
    >> >>
    >> >> Which is just a string that has the link name, then the link target.

    > So
    >> >> I would need to programmatically build a link from this field. I have
    >> >> found some other ways around this, but they involve Regular
    >> >> Expressions
    >> >> in vbscript and I was wondering if there was a more efficient way of
    >> >> doing this. My database table looks like this,
    >> >>
    >> >> Username - the username of the user
    >> >> Userlinks - the links as above, Fiscal; swvtc/fiscal/fiscaldata.asp:
    >> >> Records; swvtc/records/recordsdata.asp:
    >> >>
    >> >> I am open to any sort of delimeter instead of the : and ;.
    >> >>
    >> >> This will be used for an Intranet front page and would allow the users

    > to
    >> >> have "quick links" on the front page.
    >> >>
    >> >> Thanks,
    >> >> Drew Laing
    >> >>
    >> >
    >> >

    >>
    >>

    >
    >
    Drew, Nov 4, 2004
    #7
  8. You create an HTML form <form> and have the form submit data to an ASP page
    that processes the data and updates your database. That's the generic
    explanation anyway.

    I suggest starting a new thread if you would like to discuss this further,
    as the topic has now changed.

    Ray at work



    "Drew" <> wrote in message
    news:...


    > How can I make an insert page that has checkboxes that the users check
    > which links they want and then it inserts a new record for each item
    > checked? I don't think that I have ever done this.
    >
    Ray Costanzo [MVP], Nov 4, 2004
    #8
  9. Or see some ASP-db tutorials, which will probably answer 90% of the
    question(s)...




    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:...
    > You create an HTML form <form> and have the form submit data to an ASP

    page
    > that processes the data and updates your database. That's the generic
    > explanation anyway.
    >
    > I suggest starting a new thread if you would like to discuss this further,
    > as the topic has now changed.
    >
    > Ray at work
    >
    >
    >
    > "Drew" <> wrote in message
    > news:...
    >
    >
    > > How can I make an insert page that has checkboxes that the users check
    > > which links they want and then it inserts a new record for each item
    > > checked? I don't think that I have ever done this.
    > >

    >
    Aaron [SQL Server MVP], Nov 4, 2004
    #9
  10. Drew

    Drew Guest

    I didn't mean to sound like a newbie, I meant that I had never looped
    anything, I have done regular inserts for 1 record at a time, but not for
    multiple records. I will research, see what I find and if I have any
    questions, I will ask!

    thanks,
    Drew


    "Aaron [SQL Server MVP]" <> wrote in message
    news:...
    > Or see some ASP-db tutorials, which will probably answer 90% of the
    > question(s)...
    >
    >
    >
    >
    > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    > message news:...
    >> You create an HTML form <form> and have the form submit data to an ASP

    > page
    >> that processes the data and updates your database. That's the generic
    >> explanation anyway.
    >>
    >> I suggest starting a new thread if you would like to discuss this
    >> further,
    >> as the topic has now changed.
    >>
    >> Ray at work
    >>
    >>
    >>
    >> "Drew" <> wrote in message
    >> news:...
    >>
    >>
    >> > How can I make an insert page that has checkboxes that the users check
    >> > which links they want and then it inserts a new record for each item
    >> > checked? I don't think that I have ever done this.
    >> >

    >>

    >
    >
    Drew, Nov 4, 2004
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    808
    Kevin Spencer
    May 17, 2005
  2. Blue®
    Replies:
    4
    Views:
    790
    Blue®
    Sep 27, 2003
  3. Sound
    Replies:
    2
    Views:
    436
    Randy Webb
    Sep 28, 2006
  4. VUNETdotUS
    Replies:
    25
    Views:
    450
    Thomas 'PointedEars' Lahn
    Nov 10, 2007
  5. jr
    Replies:
    3
    Views:
    414
Loading...

Share This Page