Discussions
Categories
Groups
Advertisement
Child Item
Home
Topics
Technology & Internet
Software & Web Development
Development
MySQL display query
marno21
Hi lads,
Created my first mySQL table today so apologies if this is a stupid question.
If I have a table with 4 columns, and one column has a three digit number, is it conveniently possible for me to display a certain string whenever that row is called upon?
For example, if 6/7 rows have id = 201, they display "Cork" instead of 201 when displaying the information on a html page
Find more posts tagged with
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of
Advertisement
Advertisement
Comments
boreder
So you'd either keep the list of what id's map to what names in another table and join them – or you could hard code them in your scripting language. Which option you choose depends on what you're doing, and how you're doing it.
For the scripting language way, you'd just put an 'if' or 'switch' statement when iterating through the rows. For example, assuming $result is the returned SQL;
foreach($result as $row){ if($row->id == "204"){ print "Cork"; }else{ print "Dublin"; } }