So, what you want is a function foo() and its inverse foo'() that does this:
foo( "some long string" ) --> 1234
foo'( 1234 ) --> "some long string"
Correct?
In other words, you want to keep the entire information content of the original string.
There are only two ways to do this:
- keep the original string, i.e. store it in a database of some sort, or
- lossless compression of the original string into a short number. While theoretically possible, the compression ratio you're asking for isn't going to be possible.
Which leaves the first option, as plenty of people here have described.
So:
You've said you already have a database with a column that stores a 4-digit number.
If that database table doesn't already have a column that stores the HTML page's absolute path, then add one.
You'll also want a UNIQUE constraint on the column with the number (and/or the other column, depending on your database design).
The rest is "just" SQL...
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.