PHP training in Chandigarh - PowerPoint PPT Presentation

About This Presentation
Title:

PHP training in Chandigarh

Description:

PHP Training in Chandigarh is provided by CBitss which is the Best PHP Training Institute in Chandigarh. – PowerPoint PPT presentation

Number of Views:33

less

Transcript and Presenter's Notes

Title: PHP training in Chandigarh


1
(No Transcript)
2
Introduction
  • What is MySql ?
  • MySql is an open source relational
    database
  • management system.
  • How MySql is related to PHP?
  • MySql acts as a back-end database server
    and
  • helps in data storage and management of
    data
  • stored at MySql database server.

3
Predefined Constant
  • MySql Fetch Constant
  • MYSQL_ASSOC Columns are returned into the array
    having the fieldname as the array index.
  • MYSQL_BOTH Columns are returned into the array
    having both a numerical index and the field name
    as the array index.
  • MYSQL_NUM Columns are returned into the array
    having a numerical index to the fields. This
    index is start with 0, the first field in the
    result.

4
PHP MySql Function
  • mysql_connect Open a connection to a MySql
    server.
  • mysql_close Close MySql connection.
  • mysql_create_db Create a MySql database.
  • mysql_error Returns the text of the error
    message from previous MySql operation.
  • mysql_fetch_assoc Fetch a result row as an
    associative array.
  • mysql_select_db Select a MySql database.

5
How to connect to MySql via PHP.
  • lt?php
  • host "localhost"
  • username "root"
  • password ""
  • mysql_connect(host,username,password)
  • or die(mysql_error())
  • ?gt

6
How to Select database in a table.
  • lt?php
  • mysql_connect("localhost", "root", "") or
    die(mysql_error())
  • mysql_select_db("dbemp") or die(mysql_error())
  • resultmysql_query("select from emp")
  • or die(mysql_error())
  • rowmysql_fetch_array(result)
  • echo "ltbrgtRoll".row'empno'
  • echo "ltbrgtName".row'name'
  • echo "ltbrgtRoll".row'Job'
  • ?gt

7
How to select values from MySql table.
  • lt?php
  • mysql_connect("localhost", "root", "") or
    die(mysql_error())
  • mysql_select_db("dbemp") or die(mysql_error())
  • resultmysql_query("select from emp")
  • or die(mysql_error())
  • echo "lttable width'20' bgcolor'lime'
    border'4' bordercolor'green'gt"
  • echo "lttrgt ltthgtEmpnolt/thgt ltthgtNamelt/thgt lt/trgt"

8
Contin
  • while(row mysql_fetch_array( result ))
  • echo "lttrgt lttdgt"
  • echo row'empno'
  • echo "lt/tdgt lttdgt"
  • echo row'name'
  • echo "lt/tdgtlt/trgt"
  • echo "lt/tablegt"
  • ?gt

9
Display data from database using fetch_assoc
function
  • sql "SELECT empno, name,Job FROM emp"
  • result conn-gtquery(sql)
  • if (result-gtnum_rows gt 0)
  • while(row result-gtfetch_assoc())
  • echo "ltbrgt Empno ". row"empno". " Name ".
    row"name". " Job" . row"Job" . "ltbrgt"
  • else
  • echo "Can't find the record"
  • conn-gtclose()
  • ?gt

10
How to insert data in a MySql Table.
  • lt?php
  • dbhost 'localhost'
  • dbuser 'root'
  • dbpass ''
  • conn mysql_connect(dbhost, dbuser, dbpass)
  • if(! conn )
  • die('Could not connect ' . mysql_error())
  • sql "INSERT INTO emp (ename,job, sal) VALUES
    ('Amit','manager','3333')"

11
Contin
  • mysql_select_db('dbemp')
  • retval mysql_query( sql, conn )
  • if(! retval )
  • die('Could not enter data ' . mysql_error())
  • echo "Entered data successfully\n"
  • mysql_close(conn)
  • ?gt

12
CBitss Technologies provide a PHP training in
Chandigarh. A well qualified trainer will train
you on all sophisticated technologies. CBitss
Technologies is ISO 90012008 certified PHP
training institute in Chandigarh.
13
Office SCO 23-24-25, Level 3 ,
Near Passport office, Above
Allahabad Bank, Sec
34A,Chandigarh. Phone 9988741983Website
http//goo.gl/aO9a4u Email
navneetlinuxexpert_at_gmail.com
Write a Comment
User Comments (0)
About PowerShow.com