Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I'm building a large dictionary of terms, MySQL-backed. Currently there are 3,223 entries in the database. I'm converting this into mobile format for handheld devices (constrained screen real-estate, limited "browser" capabilities, etc.)

Due to the limitations of the screen size, I've been asked to create named anchors that will go from the top of the list of terms, down to the next closest match of letters.

For example:

<a href="#Ba">Ba</a> <a href="#Be">Be</a> <a href="#Bi">Bi</a> <a href="#Bo">Bo</a> <a href="#Bu">Bu</a>

Each term displayed, would lack a <a name=".."> attribute unless its letter changed from the previous term's first two letters.

The first word to begin with "Be" would have an anchor that would put the user there when they selected it from the top of the page. It should look something like this:

<a id="339" href="?term=Bay">Bay</a><br /> <a id="340" href="?term=Bay_Tree">Bay Tree</a><br /> <a id="341" href="?term=Bayonet">Bayonet</a><br /> <!-- Note that the anchor changes on this first "Be" word --> <a id="342" href="?term=Beach" name="Be">Beach</a><br />

It all works right now, except adding the named anchors at their respective "first instance" of words that begin with $letter . [aeiou];.

How can I detect the change in the words, as I'm outputting them one by one from my results set?

Here's a sample of the words from the live db. I've added indicators below, where anchors would logically be inserted:

__DATA__ 1930: Nails <-- #Na here 1931: Naked 1932: Name 1933: Napkin 1934: Narcotics 1935: Narrow 1936: Nature 1937: Nausea 1938: Navel 1939: Navy 1940: Nazi 1941: Nearsighted <-- #Ne here 1942: Neck 1943: Necklace 1944: Necktie 1945: Necromancer 1946: Need 1947: Needle 1948: Negligee 1949: Neighbour 1950: Neighbourhood 1951: Nephew 1952: Neptune 1953: Nerd 1954: Nervous_Breakdown 1955: Nest 1956: Net 1957: Nettles 1958: New 1962: New_Year 1959: News 1960: Newspaper 1961: Newspaper_Reporter 1963: Nickname <-- #Ni here 1964: Niece 1965: Night 1966: Nightclub 1967: Nightgown 1969: Nightingale 1968: Nightmare 1970: Ninepins 1971: Nipples 1972: Nobility <-- #No here 1973: Noise 1974: Noodles 1975: Noose 1976: North 1977: Northern_Lights 1978: Nose 1979: Notary 1980: Notebook 1981: November 1982: Nuclear_Bomb <-- #Nu here 1984: Numbers 1983: Numbness 1985: Nuns 1986: Nuptial 1987: Nurse 1988: Nursing 1989: Nuts 1990: Nymph

Thanks, my fellow monks.


In reply to Programatically detecting a change in letters by hacker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (4)
    As of 2021-01-21 08:29 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?