PCHomepage
Programmer
I've only just started using object oriented mysqli and I'm sure that I am overly-complicating the code. Isn't there a simpler way of doing something like this for multiple values without all the semi-duplicates?
Code:
// Values from foreach loop of uploaded files submitted from form
$FileName1 = $FileList[0];
$FileName2 = $FIleList[1];
$FileName3 = $FileList[2];
// Check if file has already been inserted
$FileQuery1 = "SELECT ID FROM fileuploads WHERE FileName = '$FileName1'";
$FileQuery2 = "SELECT ID FROM fileuploads WHERE FileName = '$FileName2'";
$FileQuery3 = "SELECT ID FROM fileuploads WHERE FileName = '$FileName3'";
$Result1 = $mysqli->query($FileQuery1);
$Result2 = $mysqli->query($FileQuery2);
$Result3 = $mysqli->query($FileQuery3);
$FileExists1 = $Result1->fetch_row();
$FileExists2 = $Result2->fetch_row();
$FileExists3 = $Result3->fetch_row();