Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles on Trending Technologies
Technical articles with clear explanations and examples
atan2() function in PHP
The atan2() function in PHP returns the arc tangent of two variables. It calculates the angle in radians between the positive x-axis and the ray from the origin to the point (val2, val1). Syntax atan2(y, x) Parameters y − The y-coordinate (dividend) x − The x-coordinate (divisor) Return Value The atan2() function returns the arc tangent of y/x in radians. The returned value is between -π and π, which represents the angle from the positive x-axis to the point (x, y). Example 1 Basic usage with positive values ...
Read MorePHP timestamp to HTML5 input type=datetime element
HTML5 datetime input elements require a specific format: YYYY-MM-DDTHH:MM:SS. In PHP, you can convert timestamps to this format using the date() function with the appropriate format string. Basic DateTime Format To format the current timestamp for HTML5 datetime input − 2024-03-28T19:12:49 Converting Specific Timestamp To convert a specific Unix timestamp to HTML5 datetime format − 2022-01-01T00:00:00 HTML Integration Using the formatted timestamp in an HTML datetime input element −
Read MoreHow can we write PHP script to get the list of MySQL database?
We can write PHP scripts to get the list of available MySQL databases using different approaches. Since the legacy MySQL extension is deprecated, we'll show modern methods using MySQLi and PDO. Using MySQLi Extension The MySQLi extension provides a simple way to list databases − Using PDO Extension PDO provides a more secure and flexible approach − Comparison Method Security Status Legacy MySQL Low Deprecated MySQLi High Active PDO High Active (Recommended) Conclusion Use ...
Read MoreHow can we create a MySQL temporary table by using PHP script?
In PHP, you can create a MySQL temporary table using database connection functions like mysqli or PDO. Temporary tables are automatically dropped when the connection ends, making them useful for storing intermediate results during complex operations. Using MySQLi Extension The modern approach uses the mysqli extension to connect and execute the CREATE TEMPORARY TABLE statement − Using PDO Extension Alternatively, you can use PDO for better error handling and database portability − Key Points Feature Temporary Table Regular Table Visibility Session only ...
Read MoreHow to write PHP script by using MySQL JOINS inside it to join two MySQL tables?
MySQL JOINs allow you to combine data from multiple tables based on related columns. In PHP, you can execute JOIN queries using database connection functions and process the results to display combined information from different tables. Sample Database Tables Let's work with two sample tables to demonstrate the JOIN operation ? mysql> SELECT * FROM tcount_tbl; +-----------------+----------------+ | tutorial_author | tutorial_count | +-----------------+----------------+ | mahran | 20 | | mahnaz ...
Read MoreHow to write PHP script to update an existing MySQL table?
In PHP, you can update existing records in a MySQL table using the SQL UPDATE statement. Modern PHP uses MySQLi or PDO extensions to interact with databases securely and efficiently. Using MySQLi (Procedural) The procedural MySQLi approach provides a straightforward way to update database records −
Read MoreHow to write PHP script to fetch data, based on some conditions, from MySQL table?
To fetch data from a MySQL table based on specific conditions, you use the WHERE clause in your SQL statement combined with PHP database functions. The WHERE clause filters records that meet specified criteria, allowing you to retrieve only the data you need. Using MySQLi (Recommended) Here's a modern approach using MySQLi to fetch records from a table where the author name is 'Sanjay' −
Read MoreWhich PHP function is used to release cursor memory associated with MySQL result?
PHP uses mysql_free_result() function to release the cursor memory associated with MySQL result. This function is part of the original MySQL extension (now deprecated) and returns no value. Syntax mysql_free_result(result); Parameters Parameter Description result Required. Specifies a result set identifier returned by mysql_query(), mysql_store_result() or mysql_use_result() Example Here's how to use mysql_free_result() to free memory after processing a MySQL query result − Modern Alternative Since the original MySQL extension is deprecated, use mysqli_free_result() with MySQLi or PDO instead − ...
Read MoreHow can we fetch all the data from MySQL table by using mysql_fetch_array() function, returning an array with the numeric index, in PHP script?
The function mysql_fetch_array() returns an array with numeric indexes when you use the constant MYSQL_NUM as the second argument. This allows you to access fetched data using numeric indexes like $row[0], $row[1], etc. Syntax mysql_fetch_array($result, MYSQL_NUM) Parameters $result − The result resource returned by mysql_query() MYSQL_NUM − Constant that specifies numeric index array Example In this example, we fetch all records from a table named 'tutorials_tbl' using mysql_fetch_array() with MYSQL_NUM to get numeric indexes − Output Tutorial ID :1 Title: Learn PHP ...
Read MoreHow can we display all the records from MySQL table with the help of PHP script?
To display all records from a MySQL table using PHP, you need to establish a database connection, execute a SELECT query, and fetch the results. Below is an example using modern PHP and MySQLi extension ? Using MySQLi Extension The following example demonstrates fetching all records from a table named tutorials_tbl ? Using PDO Extension Alternatively, you can use PDO (PHP Data Objects) for better security and flexibility ? Key Points When fetching data from MySQL with PHP, remember these important points ? fetch_assoc() ...
Read More