Assignment No - 8
Assignment No - 8
Course Objective:
Implement PL/SQL Code block for given requirements
Course Outcome:
C306.6
Design and develop application considering actual requirements and using database concepts
PHP Connectivity
PHP will require that mysqli is enabled (it is on most PHP set ups).
$db =
mysqli_connect('localhost','username','password','database_name') or
die('Error connecting to MySQL server.');
The variable $db is created and assigned as the connection string, it will be used in future steps. If there is a
failure then an error message will be displayed on the page. If it is successful you will see PHP connect to
MySQL.
Performing a database query
The mysql query is actually performed in the body of the html page, so additional php opening and closing tags
will be required. For the query we are going to specify a read of all fields from a given table. The $query
variable selects all rows in the table. You just need to use your table name.
<?php
$query = "SELECT * FROM table_name";
mysqli_query($db, $query) or die('Error querying database.');
Again the returned page in the browser should be blank and error free, if you do receive the error – ‘Error
querying database..’ check the table name is correct.
<?php
//Step1
$query = "SELECT * FROM table_name";
mysqli_query($db, $query) or die('Error querying database.');
$result = mysqli_query($db, $query);
$row = mysqli_fetch_array($result);
DBMS Lab ThirdYear Computer Engineering