Tuesday, 1 December 2015

45_mysql_select_data

MYSQL DATABASE


As we have already learn how to create database, tables in database and basic concept of editing. Now we are going to learn some other tab in MYSQL.


1) open PRIVIEGES tab from phpmyadmin




2) for localhost we are not using the password. So in localhost our password is always null. In above image you can see one link called “Add a new user”. Using that link you can also allowed to add new user and give them access which you want.




3) Till now we have learn is our SERVER IS LOCALHOST, USER NAME IS ROOT And PASSWORD is NULL.


4) Let’s understand the KEY concept in database table PK.




Select the radio button to make your filed as primary key and to make your field auto increment then select it from EXTRA tab, and click on SAVE button. For checking purpose as some default data FROM INSERT TAB.


Select data from PHPMYADMIN to .PHP Page


1) Open home.php page and write the code as specify below.


As earlier we discuss about the function, in that I have specify that php have in built function functionality.
So using that function we first of check that our localhost is working properly or not so for that php have function named mysql_coonect(servername,username.password).



In the beginning we specify “@” just for hiding the error message if our die() function fire.


After that we check that whatever database we are interested to use is present in mysql or not so for that we have another in built function named mysql_select_db() using this function u can find out that the database is present or not.


Also you can write like this as specify below



If particular database is present then it’s time to fire the select query.
Using the mysql_query() function we are able to execute the select,insert,update query.
And PHP have another function mysql_fetch_array() using this function we can retrieve one by one record from the specify column.




If our database is available and there is no syntax problem then the browser will show you the output as given below.

No comments:

Post a Comment