0% found this document useful (0 votes)
19 views1 page

Only PHP

The document contains PHP code snippets for performing CRUD operations on a database table named 'name_table'. It includes SQL statements for inserting, selecting, updating, and deleting records, as well as handling file uploads for images. Each operation is prepared and executed using PDO with appropriate parameters from user input or session data.

Uploaded by

Aymen Nadir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

Only PHP

The document contains PHP code snippets for performing CRUD operations on a database table named 'name_table'. It includes SQL statements for inserting, selecting, updating, and deleting records, as well as handling file uploads for images. Each operation is prepared and executed using PDO with appropriate parameters from user input or session data.

Uploaded by

Aymen Nadir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Insert :

$addproduit = 'INSERT INTO name_table(`name`) VALUES (:name,)';


$addproduits = $db_con->prepare($addproduit)->execute(array(
"name" => $_POST["name"],
));
Select :
$q = 'SELECT * FROM name_table WHERE name_column = :name_column2 ';
$qu = $db_con->prepare($q);
$qu->execute(array(
"name_column2" => $_SESSION["userData"]["id"]
));
$clientdata = $qu->fetchAll();

Update :
$updateclient = 'UPDATE name_table SET name_column = :name_column1 WHERE
name_column = :name_column2 ';
$update = $db_con->prepare($updateclient)->execute(array(
"name_column1" => $_POST["fullname"],
"name_column2" => $_GET["id"],
));

Deleted :
$deleteClient = 'DELETE FROM name_table WHERE name_column = :name_column1 ';
$deleteClients = $db_con->prepare($deleteClient);
$res = $deleteClients->execute(array(
"name_column1" => $_REQUEST["id"],
));
Upload Picture :
$uploaddir = './picturesProduit/' ; // ( ./picturesProduit/ => is the name of
the file we uploded in him the picture )
$uploadfile = $uploaddir . basename($_FILES["image"]['name']);
if (move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile)) {
$uploadimage = True;
}; // if image is uploaded succefly in the dossier $uploadimage become TRUE

// $_FILES["image"]["name"] => This is the source of image for used .

You might also like