So, I have made a table called supplies_table
and inside the table is id
, name
, and files
. And I also made an upload button where it can upload a pdf BLOB file into the files
column. Yes, it can upload a pdf file in the files
column but the problem is that when I upload a file to a specific row, the other rows also updates with the same pdf file I uploaded.
Here's my code:
<?php
session_start();
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "myDatabase";
$connect = mysqli_connect($servername, $username, $password, $dbname);
if(count($_FILES) > 0)
{
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
$_SESSION['id'];
$file = file_get_contents($_FILES['file']['tmp_name']);
$sql = "UPDATE supplies_table SET files = ? WHERE id=id";
$statement = $connect->prepare($sql);
$statement->bind_param('s',$file);
$current_id = $statement->execute();
}
}
mysqli_close($connect);
?>
What can I do to update just one row in the table?