Category: Programming

PHP script to download file from specific folder

 Below is a simple example of a PHP script that allows you to download file from a specific folder. You can link to this PHP file with the file name as a parameter. Create a file named download.php and add the following code: <?php // Specify the folder where your files are stored $folderPath = […]

Read More

WordPress reserved terms you should never use

 While developing WordPress theme or plugin we use different WordPress keywords or terms, additionally while handling forms fields and custom post types we have to consider what names we can use or not. The restricted names are called reserved terms. WordPress itself reserves few keywords or terms which we can not use in our coding. […]

Read More

How to upload image and PDF file using PHP

 Here is a PHP script that allows users to upload image and PDF files with a maximum size of 5 MB. The uploaded files will be renamed using the current timestamp: <?php if ($_SERVER[“REQUEST_METHOD”] == “POST” && isset($_FILES[“file”])) { $allowedExtensions = array(“jpg”, “jpeg”, “png”, “pdf”); $maxFileSize = 5 * 1024 * 1024; // 5 MB […]

Read More

Get total of MySQL column and show highest totals

 To get the total of a MySQL field and then select the three highest totals from the table, you can use the following PHP script: <?php // Assuming you have already established a MySQL connection // Retrieve the total of a field and select the three highest totals $servername = “localhost”; $username = “your_username”; $password […]

Read More

How to compare any changed data of HTML table among different rows

 In a HTML table compare every column data of every row. if any column data has changed value with respect to previous row then highlight that data. We can achieve this using JavaScript. Here’s a basic example of how you could implement this functionality: <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”UTF-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> […]

Read More

Export MySQL data into CSV using PHP

 To fetch data from a MySQL database and export it to CSV using PHP, you can follow these steps: <?php // Database connection details $servername = “localhost”; $username = “your_username”; $password = “your_password”; $dbname = “your_database_name”; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die(“Connection failed: ” […]

Read More

Print total of a variable inside while loop outside of the loop

 To accumulate values from a MySQL query inside a while loop and then calculate the total value outside the loop, you can use a variable to store the total value while iterating through the records. Here’s an example in PHP: <?php // Your database connection parameters $servername = “localhost”; $username = “your_username”; $password = “your_password”; […]

Read More

Import CSV data into MySQL using PHP

 Here’s a detailed example of how to import data from a CSV file into a MySQL database using PHP. The script processes each row one by one, displays a success message for each successfully inserted row, and stops the process if any error occurs, showing the error message. Prerequisites: Ensure you have a MySQL database […]

Read More

Boosting loading speed of your WordPress website

 In the current landscape, WordPress enjoys widespread use, leading to a surge in website creation. As this platform sees continuous growth with individuals and businesses joining in, it’s crucial to acknowledge the factors influencing website loading speed. Optimizing your website’s loading speed is pivotal. Here are some essential considerations: Optimized Plugins and Themes: Utilize plugins […]

Read More