PHP training in Chandigarh

13

description

PHP Training in Chandigarh is provided by CBitss which is the Best PHP Training Institute in Chandigarh. Visit : goo.gl/aO9a4u - PowerPoint PPT Presentation

Transcript of PHP training in Chandigarh

Page 1: PHP training in Chandigarh
Page 2: PHP training in Chandigarh

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.

Page 3: PHP training in Chandigarh

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.

Page 4: PHP training in Chandigarh

PHP MySql Functionmysql_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.

Page 5: PHP training in Chandigarh

How to connect to MySql via PHP.<?php$host = "localhost";$username = "root";$password = "";mysql_connect($host,$username,$password) or die(mysql_error());?>

Page 6: PHP training in Chandigarh

How to Select database in a table.

<?phpmysql_connect("localhost", "root", "") or die(mysql_error());mysql_select_db("dbemp") or die(mysql_error());$result=mysql_query("select * from emp")or die(mysql_error());$row=mysql_fetch_array($result);echo "<br>Roll:".$row['empno'];echo "<br>Name:".$row['name'];echo "<br>Roll:".$row['Job'];?>

Page 7: PHP training in Chandigarh

How to select values from MySql table.<?phpmysql_connect("localhost", "root", "") or die(mysql_error());mysql_select_db("dbemp") or die(mysql_error());$result=mysql_query("select * from emp")or die(mysql_error());echo "<table width='20%' bgcolor='lime' border='4' bordercolor='green'>";echo "<tr> <th>Empno</th> <th>Name</th> </tr>";

Page 8: PHP training in Chandigarh

Contin…while($row = mysql_fetch_array( $result )) { echo "<tr> <td>";

echo $row['empno'];echo "</td> <td>"; echo $row['name'];echo "</td></tr>";

} echo "</table>";?>

Page 9: PHP training in Chandigarh

Display data from database using fetch_assoc function

$sql = "SELECT empno, name,Job FROM emp";$result = $conn->query($sql);if ($result->num_rows > 0) {while($row = $result->fetch_assoc()) { echo "<br> Empno: ". $row["empno"]. " Name: ". $row["name"]. " Job:" . $row["Job"] . "<br>";} } else { echo "Can't find the record"; }$conn->close();?>

Page 10: PHP training in Chandigarh

How to insert data in a MySql Table.

<?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')";

Page 11: PHP training in Chandigarh

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);?>

Page 12: PHP training in Chandigarh

CBitss Technologies provide a PHP training in Chandigarh. A well qualified trainer will train you on all sophisticated technologies. CBitss Technologies is ISO 9001:2008 certified PHP training institute in Chandigarh.

Page 13: PHP training in Chandigarh

Office : SCO 23-24-25, Level 3 , Near Passport office, Above Allahabad Bank, Sec 34A,Chandigarh. Phone : 9988741983Website : http://goo.gl/aO9a4u Email : [email protected]