PHP Mysql
PHP Mysql
PHP MYSQL
Presented by
Md Atiqur Rahman (Polash)
Chief Technical Officer(CTO)
Doel e-Services
Web: doelhosting.com
Email: [email protected]
Mobile:01720981682
7/30/23 Web Design and Development 1
Today’s Objective
• Data Insert
• Data View
• Data Edit
• Data Delete
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add About Us</title>
</head>
</form>
if(isset($_POST['submit']))
{
$current_date=date('F d,Y');
$title=$_POST['title'];
$detail=$_POST['detail'];
$post_file= $_FILES['image']['name'];
$file_tmp= $_FILES['image']['tmp_name'];
move_uploaded_file($file_tmp,"image/$post_file");
$q ="INSERT INTO `napd_about`(`title`, `detail`,`image`,`date`) VALUES ('$title','$detail','$post_file','$current_date')";
mysqli_query($db, $q);
if($q !=''){
echo "<script>alert('your information update successfuly')</script>";
echo "<script>window.open('add_about_us.php','_self')</script>";
}
}
?>
</body>
</html>
</body>
</html>
<tr>
<td>Detail</td>
<td><textarea name="detail" rows="10"><?php echo $detail; ?></textarea></td>
</tr>
<tr>
<td>Image</td>
<td><input type="file" name="image" /></td>
<td><img src="image/<?php echo $image; ?>" style="height:100px; width:100px;"/></td>
</tr>
<tr>
<td></td>
<td> <br /><button type="submit" name="submit">Update</button></td>
</tr>
</table>
</form>
if(isset($_POST['submit']))
{
$edit_id = $_GET['id'];
$current_date=date('F d,Y');
$title=$_POST['title'];
$detail=$_POST['detail'];
$post_file= $_FILES['image']['name'];
$file_tmp= $_FILES['image']['tmp_name'];
if($post_file==''){
$q ="UPDATE `napd_about` SET `title`='$title',`detail`='$detail' WHERE id='$edit_id'";
mysqli_query($db, $q);
}else{
move_uploaded_file($file_tmp,"image/$post_file");
$q ="UPDATE `napd_about` SET `title`='$title',`detail`='$detail',`image`='$post_file' WHERE
id='$edit_id'";
mysqli_query($db, $q);
}
if(isset($_GET['id'])){
$delete_id = $_GET['id'];
echo "<script>window.open('view_about_us.php','_self')</script>";
}
?>