Download Prepared by Tanvir Hamid

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
DAY 10
End of the Php+MySQL basic part.
Prepared by Tanvir Hamid
prepared by Tanvir Hamid
Things to remember
1. Establish the connection to Mysql
by IP, username, Password
2. Create Database
3. Create Table
4. Insert values
5. Show the values
6. Close the connection
prepared by Tanvir Hamid
Connection eshtablish
Connection eshtablishment
<?php
$con= mysql_connect("localhost",“root","");
if (!$con)
{ die('Could not connect: ' . mysql_error()); }
// Your code here
?>
prepared by Tanvir Hamid
Closing a Connection
<?php
$con = mysql_connect("localhost",“root","");
Connection close
if (!$con)
{ die('Could not connect: ' . mysql_error()); }
// your code here
mysql_close($con);
?>
prepared by Tanvir Hamid
Create Database
<?php
Create the Database
$con = mysql_connect("localhost",“root","");
named tanvir
if (!$con)
{ die('Could not connect: ' . mysql_error()); }
if (mysql_query("CREATE DATABASE tanvir",$con))
{ echo "Database created"; }
else { echo "Error creating database: " . mysql_error(); }
mysql_close($con);
?>
See exercise 1.php
prepared by Tanvir Hamid
After creating database
Create Table named
data
<?php
// Create table
mysql_select_db(“tanvir", $con);
$sql = "CREATE TABLE data
( FirstName varchar(15),
LastName varchar(15),
Age int )";
// Execute query
mysql_query($sql,$con);
mysql_close($con);
?>
See exercise 1.php
prepared by Tanvir Hamid
Inserting values into Table DATA
<?php
$con = mysql_connect("localhost",“root","");
if (!$con)
{ die('Could not connect: ' . mysql_error()); }
mysql_select_db(“tanvir", $con);
mysql_query("INSERT INTO data (FirstName, LastName, Age)
VALUES (‘Tanvir', ‘Hamid', ‘23')");
mysql_query("INSERT INTO data (FirstName, LastName, Age)
VALUES (‘Nurul', ‘Ferdous', ‘28')");
mysql_close($con);
?>
See exercise 2.php
prepared by Tanvir Hamid
Show the values
<?php
$con = mysql_connect("localhost",“root","");
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db(“tanvir", $con);
$result = mysql_query("SELECT * FROM data");
while($row = mysql_fetch_array($result))
{ echo $row['FirstName'] . " " . $row['LastName'];
echo "<br />"; }
mysql_close($con);
?>
See exercise 3.php
prepared by Tanvir Hamid
Will work details at day14(Advance MySQL)
• mysql_fetch_array(),
• mysql_fetch_row(),
• mysql_fetch_assoc()
Solve the error of your course material book
&
This is the HomeWork
prepared by Tanvir Hamid
Exam will be happened at nest class
•
•
•
•
About basic php+mySQL
About HTML, CSS
Questions will be formed ZEND style
Lecture sheet and Presentations are
enough.
• Open book exam
prepared by Tanvir Hamid
Open book exam
• Remember it will be open book.
• But lectures and ppt will not helping you
at exam time Bcoz questions will be
formed on conceptual and analytical.
• NO body run the dream weaver and
XAMPP or APACHE.
• You will take any kinds of books, ebooks,
ppt with you.
prepared by Tanvir Hamid
Its not joke…Exam will be Open
book.
prepared by Tanvir Hamid
Plz turn off ur PC after finish the class
prepared by Tanvir Hamid
Related documents