Showing posts with label mysql data base. Show all posts
Showing posts with label mysql data base. Show all posts

Thursday, December 27, 2012

Common MySql Field Data Types


MySql : Common Field Data Types:
By Stephon Unomon
Google +

 

CHAR() – Fixed length field between 0 and 255 characters that can store any type of data. The length of the field is set regardless of the size of the data placed into it.

DATE – Date in YYYY-MM-DD format.

INT – Whole numbers only.  The number of digits can also be specified in parentheses, but is not necessary.

TEXT – Variable length text-only field with a maximum length of 65535 characters.

TIME – Time in hh:mm:ss format.

VARCHAR() – Variable length field between 0 and 255 characters that can store any type of data.  Unlike the CHAR() type, the length of each VARCHAR() field is determined by the data placed into it.

 

So, knowing this, let’s decipher our code example from above.

 

<?php mysql_query(“

CREATE TABLE Employees

(open the query to the DB and make this table with Employees as the name)

 

(employee_id INT,

(make this field with employee_id as the name and allow only whole numbers)

 

first_name VARCHAR(50),

(make this field with first_name as the name, allow any input, and limit it to 50 characters in length)

 

last_name VARCHAR(50)”)

(make this field with last_name as the name, allow any input, and limit it to 50 characters in length)

?>

Once you get the basic concepts, data manipulation with MySQL is not difficult. Let’s dive in a little bit more to the way tables are laid out.
 
 
Save Time While Building PHP Applications
Check Out
The #1 PHP GUI Controls

Tuesday, December 25, 2012

MySQL Data Base Select Command - PHP For Beginners (MySQL)


Putting The Data In The Base
By Stephon Unomon
Google +

 

OK! We’re connected to a MySQL database! Far out! Now what? We need to put data IN to the database and use it!

 

So, here’s how we do it.

 

 

 

First of all, you have to select the database with the mysql_select_db() command.

 

<?php

mysql_select_db("my_db") or die(mysql_error());

?>