News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Kevin van Zonneveld's Blog:
Kevin van Zonneveld
June 11, 2009 @ 07:57:21

On his blog today Kevin van Zonneveld shows how to create short URLs for your content and store them in a MySQL database.

IDs are often numbers. Unfortunately there are only 10 digits to work with, so if you have a lot of records, IDs tend to get very large. For computers that's OK. But human beings like their IDs as short as possible. So how can we make IDs shorter? Well, we could borrow characters from the alphabet as have them pose as additional numbers.... Alphabet to the rescue!

He includes some sample code that takes the shortened code and converts it back down to the correct ID and returns it out of the function. The trick compresses values down into shorter alpha-numeric strings that can make for simpler links (and smaller messages for things like twitter).

0 comments voice your opinion now!
mysql tutorial url short


blog comments powered by Disqus

Similar Posts

Lineke Kerckhoffs-Willems' Blog: ProTalk - Audio/Video Tutorials for PHP Developers

Alexander Netkachev's Blog: Installing Propel object persistence layer for Web application

BarelyFitz.com: CSS Colors - Take Control Using PHP

Lorenzo Alberton's Blog: PEAR::Pager Tutorials

SitePoint PHP Blog: Social Network Authentication - Setup & Google+


Community Events

Don't see your event here?
Let us know!


community development interview framework api opinion library language feature wordpress laravel podcast release introduction laravel5 extension voicesoftheelephpant series unittest threedevsandamaybe

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework