Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > create links using erb and mysql

Reply
Thread Tools

create links using erb and mysql

 
 
ad
Guest
Posts: n/a
 
      12-29-2009
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
 
Reply With Quote
 
 
 
 
Marnen Laibow-Koser
Guest
Posts: n/a
 
      12-29-2009
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
http://www.velocityreviews.com/forums/(E-Mail Removed)
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
link to .erb file, from .erb file Dan Thomas Ruby 4 01-26-2011 09:26 PM
Using Python and Connecting to MySQL remotely WITHOUT MySQL installedon local computer dave Python 4 11-18-2010 04:19 AM
Using ERb with $SAFE=4 Andy Morrow Ruby 0 04-02-2007 10:48 PM
using mysql client to read a file to create a table in a database in a mysql server julian Ruby 8 04-06-2006 10:29 AM
Store erb block and alter scope of erb block eval? Steve V Ruby 6 04-20-2005 09:26 PM



Advertisments