PHP Tutorial
Home
PHP Install Xampp
PHP Syntax & Comments
PHP Variables
PHP Constants
PHP Data Types
PHP Echo & Print
PHP Strings
PHP If...Else...Elseif
PHP Ternary Operator
PHP Loops
PHP Functions
PHP Arrays
PHP GET & POST
PHP Advanced
PHP Date and Time
PHP Include and Require
PHP File Upload
PHP Sessions
PHP Cookies
PHP Send Email
PHP JSON Parsing
PHP MySQL Database
PHP MySQL Introduction
PHP Connect to MySQL
PHP MySQL Create DB
PHP MySQL Create Table
PHP MySQL Insert Data
PHP MySQL Select Data
PHP MySQL Delete Data
PHP MySQL Update Data
PHP MySQL Where
If you want to store an IP address in mysql database do not hesitate to use varchar datatype because you can use INT UNSIGNED 4 (BYTE) datatype. using a complete database, you can save more space in the database.
If you enter a question then use INET_ATON () and then select the question immediately using INET_NTOA (). how you can use this function given a clear example.
Step 1 : Create Table
CREATE TABLE IF NOT EXISTS `ip_addresses_table` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ip_address` INT(4) UNSIGNED NOT NULL, PRIMARY KEY (`id`) );
Step 2 : Insert Data
INSERT INTO `ip_addresses_table` (`ip_address`) VALUES (INET_ATON("127.0.0.1"));
Step 3: Select Data
SELECT id, INET_NTOA(`ip_address`) as ip FROM `ip_addresses_table`;