Skip to content

Commit 96a0815

Browse files
committed
new lessons
1 parent be3246a commit 96a0815

File tree

105 files changed

+327
-355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+327
-355
lines changed

LESSON 1 - الدرس/index.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

LESSON 10 - الدرس/index.php

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,16 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Document</title>
7-
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
8-
</head>
9-
<body>
10-
11-
<main class="container">
12-
131

142
<?php
153
$username = "root";
164
$password = "";
175
$database = new PDO("mysql:host=localhost; dbname=codershiyar;",$username,$password);
186

7+
$sql = $database->prepare("SELECT * FROM users");
198

9+
$sql->execute();
2010

21-
if(isset($_POST['send'])){
22-
$Title = $_POST['Title'];
23-
$Content = $_POST['Content'];
24-
$Date = $_POST['Date'];
25-
$Time = $_POST['Time'];
26-
27-
$addData = $database->prepare("INSERT INTO articles(Title,Content,Date,Time)
28-
VALUES(:Title, :Content , :Date, :Time)");
11+
echo $sql->columnCount();
2912

30-
$addData->bindParam("Title",$Title);
31-
$addData->bindParam("Content",$Content);
32-
$addData->bindParam("Date",$Date);
33-
$addData->bindParam("Time",$Time);
34-
35-
if($addData->execute()){
36-
echo '<div class="alert alert-success mt-3" role="alert">
37-
تم إضافة بيانات بنجاح
38-
</div>';
39-
40-
}else{
41-
echo '<div class="alert alert-danger" role="alert">
42-
فشل إضافة بيانات
43-
</div>';
44-
echo ' ';
45-
}
46-
}
4713
?>
4814

49-
<form method="POST">
50-
Title : <input class="form-control" type="text" name="Title" required/>
51-
<br>
52-
Content : <input class="form-control" type="text" name="Content" required/>
53-
<br>
54-
Date : <input class="form-control" type="date" name="Date" required/>
55-
<br>
56-
Time : <input class="form-control" type="time" name="Time" required/>
57-
<br>
58-
<button class="btn btn-danger mt-3" type="submit" name="send">ارسال - Send</button>
59-
</form>
60-
61-
</main>
6215

63-
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
64-
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
65-
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
66-
</body>
67-
</html>
6816

LESSON 12 - الدرس/index.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
$username = "root";
3+
$password = "";
4+
$database = new PDO("mysql:host=localhost; dbname=codershiyar;",$username,$password);
5+
6+
if(isset($_POST['upload'])){
7+
$fileType = $_FILES["file"]["type"];
8+
$fileName = $_FILES["file"]["name"];
9+
$file = $_FILES["file"]["tmp_name"];
10+
11+
move_uploaded_file($file,"files/".$fileName);
12+
$position = "files/".$fileName;
13+
$uploadFile = $database->prepare("INSERT INTO files(name,type,position) VALUES(:name,:type,:position)");
14+
$uploadFile->bindParam("name",$fileName);
15+
$uploadFile->bindParam("type",$fileType);
16+
$uploadFile->bindParam("position",$position);
17+
if($uploadFile->execute()){
18+
echo 'تم رفع ملف بنجاح';
19+
}else{
20+
echo 'فشل رفع ملف';
21+
}
22+
}
23+
?>
24+
25+
<form method="POST" enctype="multipart/form-data">
26+
<input type="file" name="file" accept="image/*,video/*,audio/*" required/>
27+
<button type="submit" name="upload">رفع ملف</button>
28+
</form>
File renamed without changes.

LESSON 13 - الدرس/index.php

Lines changed: 0 additions & 40 deletions
This file was deleted.

LESSON 14 - 13 - الدرس/index.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
$username = "root";
3+
$password = "";
4+
$database = new PDO("mysql:host=localhost; dbname=codershiyar;",$username,$password);
5+
6+
$myFiles = $database->prepare("SELECT * FROM files WHERE fileType = 'image/jpeg' ");
7+
$myFiles->execute();
8+
9+
foreach($myFiles AS $data){
10+
$getFile = "data:" . $data['fileType'] . ";base64,".base64_encode($data['file']);
11+
echo "<a href='" . $getFile. "' download>" .$data['fileName'] . "</a> <br>";
12+
echo '<img src="' .$getFile . '" width="300px" />';
13+
14+
}
15+
16+
if(isset($_POST['upload'])){
17+
$fileName = $_FILES['file']["name"];
18+
$fileType = $_FILES['file']["type"];
19+
$fileData = file_get_contents( $_FILES['file']["tmp_name"]);
20+
21+
$addFile = $database->prepare("INSERT INTO files(file,fileName,fileType)
22+
VALUES(:file ,:fileName,:fileType)");
23+
24+
$addFile->bindParam("file",$fileData);
25+
$addFile->bindParam("fileName",$fileName);
26+
$addFile->bindParam("fileType",$fileType);
27+
28+
if($addFile->execute()){
29+
echo 'تم حفظ ملف';
30+
}else{
31+
echo 'فشل تخزين ملف';
32+
}
33+
34+
}
35+
36+
37+
38+
?>
39+
40+
<form method="POST" enctype="multipart/form-data">
41+
42+
<input type="file" name="file" required/>
43+
44+
<button type="submit" name="upload" >حفظ ملف</button>
45+
</form>

LESSON 14 - الدرس/index.php

Lines changed: 0 additions & 45 deletions
This file was deleted.

LESSON 15 - الدرس/index.php

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
2-
32
<?php
43
$username = "root";
54
$password = "";
65
$database = new PDO("mysql:host=localhost; dbname=codershiyar;",$username,$password);
76

8-
if(isset($_GET['btn-search'])){
9-
$SEARCH = $database->prepare("SELECT * FROM users WHERE name LIKE :value
10-
OR Country LIKE :value OR Password LIKE :value");
11-
$SEARCH_VALUE = "%".$_GET['search']."%";
127

13-
$SEARCH->bindParam("value",$SEARCH_VALUE);
14-
$SEARCH->execute();
158

16-
foreach($SEARCH AS $data){
9+
$getItems = $database->prepare("SELECT * FROM products");
10+
$getItems->execute();
1711

18-
echo '<div class="card text-white bg-danger mb-3" style="max-width: 18rem;">
19-
<div class="card-header">' .$data['name'] .'</div>
12+
foreach($getItems AS $data){
13+
echo '<div class="card text-white bg-success mb-3" style="max-width: 18rem;">
14+
<div class="card-header">منتج - ' . $data['Id']. '</div>
2015
<div class="card-body">
21-
<h5 class="card-title">' .$data['Country'] .'</h5>
22-
<p class="card-text">' .$data['Age'] .'</p>
16+
<h5 class="card-title">' . $data['Name'] . '</h5>
17+
<p class="card-text">' .$data['Price']. ' </p>
18+
<form method="POST"> <button class="btn btn-danger" type="submit" name="remove" value="'.$data['Id'] .' ">X - حذف </button></from/>
19+
2320
</div>
24-
</div>
25-
';
21+
</div>';
22+
23+
24+
}
25+
26+
if(isset($_POST['remove'])){
27+
$removeProduct = $database->prepare("DELETE FROM products WHERE Id = :id ");
28+
$getId = $_POST['remove'];
29+
$removeProduct->bindParam("id",$getId);
2630

31+
if($removeProduct->execute()){
32+
echo 'تم حذف بنجاح';
33+
header("Location: index.php");
34+
}else{
35+
echo 'فشل حذف';
2736
}
2837
}
2938
?>
3039

31-
<form method="GET" >
32-
<input class="form-control " style="display:inline-block; width:300px; " type="text" name="search" placeholder="search ...." />
33-
<button class="btn btn-outline-warning" type="submit" name="btn-search">Search - بحث</button>
34-
</form>
3540

File renamed without changes.

LESSON 16 - الدرس/index.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,42 @@
44
$password = "";
55
$database = new PDO("mysql:host=localhost; dbname=codershiyar;",$username,$password);
66

7-
if(isset($_GET['filter'])){
8-
$products = $database->prepare("SELECT * FROM products WHERE Price
9-
BETWEEN :startNumber AND :endNumber");
10-
$products->bindParam("startNumber",$_GET['startNumber']);
11-
$products->bindParam("endNumber",$_GET['endNumber']);
12-
13-
$products->execute();
14-
foreach( $products AS $myProducts){
15-
echo '<div class="card bg-light mb-3" style="max-width: 18rem;">
16-
<div class="card-header">' . $myProducts['Name'] .'</div>
17-
<div class="card-body">
18-
<h5 class="card-title">' . $myProducts['Price'] .' السعر </h5>
7+
$removeItem = $database->prepare("DELETE FROM files WHERE Id = 2");
8+
$removeItem->execute();
9+
10+
$getItems = $database->prepare("SELECT * FROM products");
11+
$getItems->execute();
12+
13+
foreach($getItems AS $data){
14+
echo '<div class="card text-white bg-success mb-3" style="max-width: 18rem;">
15+
<div class="card-header">منتج - ' . $data['Id']. '</div>
16+
<div class="card-body">
17+
<h5 class="card-title">' . $data['Name'] . '</h5>
18+
<p class="card-text">' .$data['Price']. ' </p>
19+
<form method="POST"> <button class="btn btn-danger" type="submit" name="remove" value="'.$data['Id'] .' ">X - حذف </button></from/>
20+
1921
20-
</div>
21-
</div>';
22+
<a href="edit.php?edit='. $data['Id'].'" class="btn btn-light" type="submit" name="edit" >تعديل</a>
23+
24+
25+
</div>
26+
</div>';
27+
28+
2229
}
23-
}else{
24-
$products = $database->prepare("SELECT * FROM products");
25-
$products->execute();
26-
foreach( $products AS $myProducts){
27-
echo '<div class="card bg-light mb-3" style="max-width: 18rem;">
28-
<div class="card-header">' . $myProducts['Name'] .'</div>
29-
<div class="card-body">
30-
<h5 class="card-title">' . $myProducts['Price'] .' السعر </h5>
31-
32-
</div>
33-
</div>';
3430

35-
}
31+
if(isset($_POST['remove'])){
32+
$removeProduct = $database->prepare("DELETE FROM products WHERE Id = :id ");
33+
$getId = $_POST['remove'];
34+
$removeProduct->bindParam("id",$getId);
35+
36+
if($removeProduct->execute()){
37+
echo 'تم حذف بنجاح';
38+
header("Location: index.php");
39+
}else{
40+
echo 'فشل حذف';
41+
}
3642
}
3743
?>
3844

3945

40-
<form method="GET">
41-
42-
<input type="number" name="startNumber">
43-
<input type="number" name="endNumber">
44-
<button type="submit" name="filter">فلتر بيانات</button>
45-
</form>

LESSON 16 - الدرس/products.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- https://www.phpmyadmin.net/
44
--
55
-- Host: 127.0.0.1
6-
-- Generation Time: Aug 16, 2020 at 11:42 AM
6+
-- Generation Time: Aug 16, 2020 at 10:22 AM
77
-- Server version: 10.4.13-MariaDB
88
-- PHP Version: 7.4.8
99

0 commit comments

Comments
 (0)