Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-05-2010, 02:30 PM Auto Create Letters?
Novice Talker

Posts: 9
Trades: 0
Hello All,

I am trying to create a sort of grid.

For example, the following fields would be present in the table:

Location
North
East
South
West

Basically I want a script where i could type in 'B2' (This would be the location field) and after i click submit it would calculate that north was B1, south was B3, east was C2 and west was A2.

would these need to be seperate fields (one field for B and one for 2) or can this be calculated to fit into one field in the mysql database?

Thanks for your help in advance!
L2crossy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-06-2010, 01:48 AM Re: Auto Create Letters?
Stephen.'s Avatar
Average Talker

Posts: 22
Name: Stephen
Trades: 0
Well a far simpler way would be to have X and Y both as integers as then it's +1 and -1 on each. If you specifically wanted it like A1 etc. It wouldn't be difficult to format it so it changes the X to a character instead.
Stephen. is offline
Reply With Quote
View Public Profile
 
Old 01-06-2010, 07:35 AM Re: Auto Create Letters?
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I've never done or seen this in php, but I guess it's possible to just use numbers instead and when printing them, adding a fix number and have the number converted into a ASCII character. All characters have a number in the ASCII table (can't remeber where it starts), so A would be represented by lets say 63. B=64, C=65 and so on. After Z comes a, b, c and so on.

So you could simply have two fields, X and Y coordinate, which are both numbers. A coordinate could then be i.e. (2,5). By adding 63 (again, dont remeber the real number but you can find ASCII tables on the web) you would get (65,68) and by converting them to characters you would get (C,F).

EDIT: And, the point being that is is simpler to find the fileds next to the one selected when representing them with numbers. To find north, add 1 to Y. To find south, substract 1 from Y. East and west would be X+1 and X-1. In the same manner, north east would be (x+1, Y+1).
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.

Last edited by lizciz; 01-06-2010 at 07:38 AM..
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Reply     « Reply to Auto Create Letters?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12160 seconds with 12 queries