Loop through a table to fetch all records with a particular ID and delete the corresponding files in a folder only deleting one file in folder in php

Advertisements I tried to query a table to get all records with a particular ID so as to delete the records from the table as well as unlink the corresponding files from a folder on the server but only the first file is getting deleted while all records are getting deleted as it should be.… Read More Loop through a table to fetch all records with a particular ID and delete the corresponding files in a folder only deleting one file in folder in php

PHP – how to convert array of values to array with nested keys from values of first array?

Advertisements I have this array: $input = [‘a’, ‘b’, ‘c’, ‘d’]; the output should be: $output = convertArrayValues($input, ‘final’); $output[‘a’][‘b’][‘c’][‘d’] = ‘final; I need code for convertArrayValues() method which will do the job of converting: $input = [‘a’, ‘b’, ‘c’, ‘d’]; into: $output[‘a’][‘b’][‘c’][‘d’] = ‘final; Dumped array input: array:4 [ 0 => "a" 1 =>… Read More PHP – how to convert array of values to array with nested keys from values of first array?

Show images only from checked (checkbox) directory using PHP

Advertisements $directory = ‘uploads/mainfolder’; mainfolder –subfolder1 –subfolder2 There will be some subfolders inside the folder ‘mainfolder’ ( say subfolder1, subfolder2 etc ) There should be a checkbox infront of subfolder1, subfolder2 etc.. Inside subfolder1, subfolder2 there will be some images So as per checked and submits it should display all the images from the checked… Read More Show images only from checked (checkbox) directory using PHP

In PHP how do you send data through a form without any data inputs apart from buttons?

Advertisements Trying to find out which button the user has pressed. I want to get the value that is in the form-label when the corresponding button is pressed. Is this possible? Thanks index.php <html> <form action="./process.php" method="post"> <?php for ($index = 1; $index <= 10; $index++) { echo "<br>"; echo "<label>$index</label>"; echo "<input type=\"submit\" value=\"Submit\">";… Read More In PHP how do you send data through a form without any data inputs apart from buttons?