create links using erb and mysql

Discussion in 'Ruby' started by ad, Dec 29, 2009.

  1. ad

    ad Guest

    Hi,
    I have a database directory.

    On my home page,
    I have these links for (which I handle manually for now):
    A B C D E......(upto ) Z

    Each link is hyperlinked only if there is a name starting with that
    letter. If there is no name starting with that letter then that letter
    will be not be hyperlinked.

    e.g. C will remain as just text if there is no name starting with C in
    the db.

    Further, clicking on A takes me to another page,
    where there are these links:
    AA-AB, AC-AD,....
    as before,any link e.g. AC-AD will be hyperlinked only if there is any
    name in the database which starts with Ac or Ad.

    Clicking on any link, eg. AC-AD will be take us to the final page,
    where through a DB query I display all the names starting with AC-AD.

    Except for the final page, I am the handling other links (A,B, AA-AB)
    manually so far.

    Is there a way to dynamically assign the hyperlinks through a db
    query?

    I know how to create the html using erb.

    -ad
     
    ad, Dec 29, 2009
    #1
    1. Advertising

  2. Ad Ad wrote:
    > Hi,
    > I have a database directory.
    >
    > On my home page,
    > I have these links for (which I handle manually for now):
    > A B C D E......(upto ) Z
    >
    > Each link is hyperlinked only if there is a name starting with that
    > letter. If there is no name starting with that letter then that letter
    > will be not be hyperlinked.
    >

    [...]
    > Is there a way to dynamically assign the hyperlinks through a db
    > query?


    The interface you just described seems like a bit of a disaster, and
    there are probably nicer ways to do it. But...

    It should be possible to see if you can retrieve one record from the DB
    in the relevant alphabetic range. If so, then make a link. If not,
    don't. It's that simple.

    >
    > I know how to create the html using erb.


    You might want to look at Haml, which gives you prettier syntax and CSS
    abstraction.

    >
    > -ad


    Best,
    --
    Marnen Laibow-Koser
    http://www.marnen.org

    --
    Posted via http://www.ruby-forum.com/.
     
    Marnen Laibow-Koser, Dec 29, 2009
    #2
    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. dave
    Replies:
    4
    Views:
    1,373
    Steve Holden
    Nov 18, 2010
  2. Steve V
    Replies:
    6
    Views:
    238
    Steve V
    Apr 20, 2005
  3. julian
    Replies:
    8
    Views:
    450
    Avatar
    Apr 6, 2006
  4. Andy Morrow

    Using ERb with $SAFE=4

    Andy Morrow, Apr 2, 2007, in forum: Ruby
    Replies:
    0
    Views:
    110
    Andy Morrow
    Apr 2, 2007
  5. Dan Thomas

    link to .erb file, from .erb file

    Dan Thomas, Jan 26, 2011, in forum: Ruby
    Replies:
    4
    Views:
    167
    Dan Thomas
    Jan 26, 2011
Loading...

Share This Page