Answer the question
In order to leave comments, you need to log in
Checking an existing record in mysql using php?
The task is to scan the directory with files for * .zip, let's say we got the result
files
1.zip
2.zip
3.zip
...
...
183.zip
$dir = "/home/main/files";
$list = scandir($dir);
foreach ($list as $item)
{
echo "$item" . PHP_EOL;
}
$dir = "/home/main/files";
$list = scandir($dir);
foreach ($list as $item)
{
$connect->query("INSERT INTO `cloud` (`id`, `file_name`, `date`) VALUES (NULL, '$item', NULL)");
echo "$item" . PHP_EOL;
}
Answer the question
In order to leave comments, you need to log in
It is better to do a check either with a count request or generally make 1 request, select everything and check in php in_array()
so as not to climb into the database every time. But it depends on the number of records in the database.
Or maybe an example, preferably simpler, of how it's done in order to understand the logic of how it all works
Records are small 2000
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question