Bonsoir à tous.

S'il vous plaît j'aimerais transférer mes requêtes MySQLi qui comporte beaucoup de failles SQL. Ne comprenant pas encore très bien le concept des requêtes préparée en PDO, je sollicite votre aide pour m'aider à corriger mon code ci-après afin qu'il soit TOTALEMENT en requêtes préparées PDO:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
//branch_list
<?php
	$i = 1;
	$qry = $conn->query("SELECT * FROM branches order by street asc,city asc, state asc ");
	while($row= $qry->fetch_assoc()):
?>
 
//classes.php
<?php
	$i = 1;
	$qry = $conn->query("SELECT * FROM classes order by level asc, section asc ");
	while($row= $qry->fetch_assoc()):
?>
 
//edit_branch.php
<?php
include 'db_connect.php';
$qry = $conn->query("SELECT * FROM branches where id = ".$_GET['id'])->fetch_array();
foreach($qry as $k => $v){
	$$k = $v;
}
include 'new_branch.php';
?>
 
//edit_parcel.php
<?php
include 'db_connect.php';
$qry = $conn->query("SELECT * FROM parcels where id = ".$_GET['id'])->fetch_array();
foreach($qry as $k => $v){
	$$k = $v;
}
include 'new_parcel.php';
?>
 
//edit_result.php
<?php
include 'db_connect.php';
$qry = $conn->query("SELECT r.*,concat(s.firstname,' ',s.middlename,' ',s.lastname) as name,s.student_code,concat(c.level,'-',c.section) as class FROM results r inner join classes c on c.id = r.class_id inner join students s on s.id = r.student_id where r.id = ".$_GET['id'])->fetch_array();
foreach($qry as $k => $v){
	$$k = $v;
}
include 'new_result.php';
?>
 
//edit_staff.php
<?php
include 'db_connect.php';
$qry = $conn->query("SELECT * FROM users where id = ".$_GET['id'])->fetch_array();
foreach($qry as $k => $v){
	$$k = $v;
}
include 'new_staff.php';
?>
 
//edit_user.php
<?php
include 'db_connect.php';
$qry = $conn->query("SELECT * FROM users where id = ".$_GET['id'])->fetch_array();
foreach($qry as $k => $v){
	$$k = $v;
}
include 'new_user.php';
?>
 
//home.php
<?php echo $conn->query("SELECT * FROM branches")->num_rows; ?>
 
<?php echo $conn->query("SELECT * FROM parcels")->num_rows; ?>
 
<?php echo $conn->query("SELECT * FROM users where type != 1")->num_rows; ?>
 
<?php echo $conn->query("SELECT * FROM parcels where status = {$k} ")->num_rows; ?>
 
//index.php
if(!isset($_SESSION['system'])){
 
    $system = $conn->query("SELECT * FROM system_settings")->fetch_array();
    foreach($system as $k => $v){
      $_SESSION['system'][$k] = $v;
    }
  }
 
//login.php
$system = $conn->query("SELECT * FROM system_settings")->fetch_array();
    foreach($system as $k => $v){
      $_SESSION['system'][$k] = $v;
    }
 
//manage_user.php
if(isset($_GET['id'])){
$user = $conn->query("SELECT * FROM users where id =".$_GET['id']);
foreach($user->fetch_array() as $k =>$v){
	$meta[$k] = $v;
}
}
 
//new_parcel.php
<?php 
    $branches = $conn->query("SELECT *,concat(street,', ',city,', ',state,', ',zip_code,', ',country) as address FROM branches");
    while($row = $branches->fetch_assoc()):
?>
 
<?php 
    $branches = $conn->query("SELECT *,concat(street,', ',city,', ',state,', ',zip_code,', ',country) as address FROM branches");
    while($row = $branches->fetch_assoc()):
?>
 
//new_staff.php
<?php
    $branches = $conn->query("SELECT *,concat(street,', ',city,', ',state,', ',zip_code,', ',country) as address FROM branches");
    while($row = $branches->fetch_assoc()):
?>
 
//parcel_list.php
<?php
	$i = 1;
	$where = "";
	if(isset($_GET['s'])){
		$where = " where status = {$_GET['s']} ";
	}
	if($_SESSION['login_type'] != 1 ){
		if(empty($where))
			$where = " where ";
		else
			$where .= " and ";
			$where .= " (from_branch_id = {$_SESSION['login_branch_id']} or to_branch_id = {$_SESSION['login_branch_id']}) ";
	}
	$qry = $conn->query("SELECT * from parcels $where order by  unix_timestamp(date_created) desc ");
	while($row= $qry->fetch_assoc()):
?>
AIDEZ-MOI S'IL VOUS PLAÎT A TRANSFORMER MON CODE EN REQUÊTES PREPAREES PDO.

Merci d'avance.