Saturday, January 23, 2016

Bangla PHP OOP and MySQLi CRUD Tutorial (Part-04)

Related Code (update.php):
include 'inc/header.php'; 
include "config.php";
include "Database.php";

 $id = $_GET['id'];
 $db = new Database();
 $query = "SELECT * FROM tbl_user WHERE id=$id";
 $getData = $db->select($query)->fetch_assoc();
 $name  = mysqli_real_escape_string($db->link, $_POST['name']);
 $email = mysqli_real_escape_string($db->link, $_POST['email']);
 $skill = mysqli_real_escape_string($db->link, $_POST['skill']);
 if($name == '' || $email == '' || $skill == ''){
  $error = "Field must not be Empty !!";
 } else {
  $query = "UPDATE tbl_user
  name  = '$name',
  email = '$email',
  skill = '$skill'
  WHERE id = $id";

  $update = $db->update($query);

 echo "<span style='color:red'>".$error."</span>";
<form action="update.php?id=<?php echo $id;?>" method="post">
  <td><input type="text" name="name" 
  value="<?php echo $getData['name'] ?>"/></td>
  <td><input type="text" name="email"
  value="<?php echo $getData['email'] ?>"/></td>

  <td><input type="text" name="skill" 
  value="<?php echo $getData['skill'] ?>"/></td>
  <input type="submit" name="submit" value="Update"/>
  <input type="reset" Value="Cancel" />
  <input type="submit" name="delete" Value="Delete" />

<a href="index.php">Go Back</a>
<?php include 'inc/footer.php'; ?>

How to practice tutorials…

  • Make a team with your friends (Member should be 4/5).
  • Start to practice one tutorial series along with them.
  • Don’t try to collect source code. Type the code while watching the tutorial.
  • If you face any problem, discuss with team members to solve quickly.