Answer the question
In order to leave comments, you need to log in
How to check a database table for the existence of a record?
In the module I enter the name of the skin in the input field and after that I load the database file for import
I write the name of the new skin to the database
move_uploaded_file($this->request->files['import']['tmp_name'], $filename);
$skin_name = $this->request->post['skin_name'];
$this->db->query("INSERT INTO `oc_testtheme_skin` (`skin_name`) VALUES ('$skin_name');");
move_uploaded_file($this->request->files['import']['tmp_name'], $filename);
$query = $this->db->query("SELECT oc_testtheme_skin FROM skin_name");
$existedSkinname = $query->rows;
if (in_array($this->request->post['skin_name'], $existedSkinname)) {
echo "exists";
}
Answer the question
In order to leave comments, you need to log in
SELECT skin_name FROM oc_testtheme_skin
as an option, make the field UNIQUE and do the insert
INSERT IGNORE
or
INSERT ..... ON DUPLICATE KEY UPDATE
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question