PHP Journal Arman
PHP Journal Arman
PHP Journal Arman
INDEX
NO DESCRIPTION PAGE NO
1 Create a form as given below. 2 To 4
1
Arman Savsaiya
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Admin</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-
EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="row">
</div>
<div class="main">
<div class="row">
<div>
</div>
<div>
</div>
2
Arman Savsaiya
<div>
<label class="form-label">City:-</label>
</div>
<div>
</div>
<div>
<label class="form-label">Standard:-</label>
</div>
<div>
</div>
</div>
</form>
</div>
</div>
</body>
</html>
3
Arman Savsaiya
Q-2 Do Crud Operation (Insert, Update, Delete, Select) in Above Form. Data
will be shown as image given below. (Insert Minimum 10 record).
Ans:--
• Connect.php
<?php
error_reporting(0);
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "student";
if ($conn->connect_error) {
die("error is :".$conn->connect_error);
}
else{
//echo "connect succesfull";
}
?>
• Insert
<?php
require_once('connect.php');
4
Arman Savsaiya
if(isset($_POST['submit']))
{
// print_r($_POST);
// exit();
//print_r($_FILES);
$rollno=$_POST['rollno'];
$name=$_POST['name'];
$city=$_POST['city'];
$contact=$_POST['p_contact'];
$standard=$_POST['standard'];
$new_path = "upload/".$_FILES['file']['name'];
$old_path = $_FILES['file']['tmp_name'];
move_uploaded_file($old_path,$new_path);
$file = $_FILES['file']['name'];
if ($rollno && $name && $city && $contact && $standard && $file !== "")
{
if($ans == 1)
{
header('location:dashboard.php');
}
else
{
echo "error";
}
}
else
{
echo "Some filed Empty";
}
}
?>
• Update
<?php
require_once('connect.php');
$id = $_GET['up'];
5
Arman Savsaiya
if(isset($_POST['update']))
{
$rollno=$_POST['rollno'];
$name=$_POST['name'];
$city=$_POST['city'];
$contact=$_POST['p_contact'];
$standard=$_POST['standard'];
$ans = $conn->query($sql);
if($ans == 1)
{
// echo "succesfully data Updated.";
header('location:dashboard.php');
}
else{
echo 'error';
}
}
?>
• Delete
if(isset($_GET['del']))
{
$delete = $_GET['del'];
6
Arman Savsaiya
{
echo "succesfully data deleted.";
header('location:index.php');
else{
echo 'deleted not';
}
}
Q-3 Data Should be shown City wise in Ascending Order in Above Form.
Ans:-
$display = "SELECT * FROM student_data ORDER BY city ASC";
$result = $conn->query($display);
7
Arman Savsaiya
$result = $conn->query($display);
$roll2=$_POST["roll"];
if(isset($_POST["search"])){
$result= mysqli_query($con,$qur);
foreach($result as $row){
?>
<tr>
</tr>
8
Arman Savsaiya
<?php
$roll2=$_POST["roll"];
if(isset($_POST["Show"])){
$result= mysqli_query($con,$qur);
foreach($result as $row){
?>
<tr>
</tr>
<?php
?>
</table>
9
Arman Savsaiya
10