Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
WEB DEVELOPMENT
PHP
PRESENTATORS
MD. AL-MAMUN SARKAR
PHP MYSQL
Connection
$conn = new mysqli(server, username, password,
dbname);
$conn = mysqli_connect(server, username, password,
dbna...
Query
$conn->query($sql)
mysqli_query($conn, $sql)
Select OOP
$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = $conn->query($sql);
if ($result->num_rows > 0)...
Select Procedural
$sql = "SELECT * FROM students";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) ...
Insert
$sql = "INSERT INTO users(firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com')";
mysqli_query($co...
Update
$sql = "UPDATE users SET lastname='Doe' WHERE id=2";
$conn->query($sql)
Delete
$sql = "DELETE FROM students WHERE id=3";
mysqli_query($conn, $sql)
QUESTION
?
THANK
YOU
Upcoming SlideShare
Loading in …5
×

Database Management - Lecture 4 - PHP and Mysql

Database Management - Lecture 4 - PHP and Mysql

  • Login to see the comments

Database Management - Lecture 4 - PHP and Mysql

  1. 1. WEB DEVELOPMENT
  2. 2. PHP PRESENTATORS MD. AL-MAMUN SARKAR
  3. 3. PHP MYSQL
  4. 4. Connection $conn = new mysqli(server, username, password, dbname); $conn = mysqli_connect(server, username, password, dbname);
  5. 5. Query $conn->query($sql) mysqli_query($conn, $sql)
  6. 6. Select OOP $sql = "SELECT id, firstname, lastname FROM MyGuests"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]; } } else { echo "0 results"; }
  7. 7. Select Procedural $sql = "SELECT * FROM students"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { echo "id: " . $row["id"]; } } else { echo "0 results"; }
  8. 8. Insert $sql = "INSERT INTO users(firstname, lastname, email) VALUES ('John', 'Doe', 'john@example.com')"; mysqli_query($conn, $sql)
  9. 9. Update $sql = "UPDATE users SET lastname='Doe' WHERE id=2"; $conn->query($sql)
  10. 10. Delete $sql = "DELETE FROM students WHERE id=3"; mysqli_query($conn, $sql)
  11. 11. QUESTION ?
  12. 12. THANK YOU

×