Digits

suppish

New Member
How do read a certain digit from a database? For example, a series of numbers is stored in a data base i.e.(1543763). How do I read just one of those digits and not the entire number?
 

anmolmark

New Member
A digit is a symbol (a numeral symbol such as "3" or "7") used in combinations (such as "37") to represent numbers in positional numeral systems. The name "digit" comes from the fact that the 10 digits (ancient Latin digita meaning fingers) of the hands correspond to the 10 symbols of the common base 10 number system, i.e. the decimal (ancient Latin adjective dec. meaning ten) digits.Digit may refer to:

* Digit (anatomy), one of several most distal parts of a limb—fingers, thumbs, and toes on hands and feet
* Numerical digit, as used in mathematics or computer science
* Hexadecimal, representing a four-bit number
* Dit or digit, synonym of Ban (information), a unit of information entropy
 
It's just in one field.

Unless I'm missing something, this seems almost too simple. Get the whole field from the database then use a substring function for whatever language you're using, to extract the desired digit. If the number is stored as a numeric value instead of a string, you may need to convert to a string first. In PHP, you can do it like this, where $numfield is the value from the data base and $digpos is the position of the digit you want (first is zero):
$strfield = strval($numfield);
$digit = substr($strfield, $digpos, 1); ;)
 
Top