-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.php
More file actions
37 lines (32 loc) · 809 Bytes
/
function.php
File metadata and controls
37 lines (32 loc) · 809 Bytes
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
<?php
function upload_image()
{
if(isset($_FILES["product_image"]))
{
$extension = explode('.', $_FILES['product_image']['name']);
$new_name = rand() . '.' . $extension[1];
$destination = 'assets/img/' . $new_name;
move_uploaded_file($_FILES['product_image']['tmp_name'], $destination);
return $new_name;
}
}
function get_image_name($product_id)
{
include('db.php');
$statement = $connection->prepare("SELECT image FROM products WHERE id = '$product_id'");
$statement->execute();
$result = $statement->fetchAll();
foreach($result as $row)
{
return $row["image"];
}
}
function get_total_all_records()
{
include('db.php');
$statement = $connection->prepare("SELECT * FROM products");
$statement->execute();
$result = $statement->fetchAll();
return $statement->rowCount();
}
?>