MySQL Articles

Page 2 of 355

How can we write PHP script to get the list of MySQL database?

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 2K+ Views

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 More

How can we create a MySQL temporary table by using PHP script?

radhakrishna
radhakrishna
Updated on 15-Mar-2026 2K+ Views

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 More

How to write PHP script by using MySQL JOINS inside it to join two MySQL tables?

mkotla
mkotla
Updated on 15-Mar-2026 5K+ Views

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 More

How to write PHP script to update an existing MySQL table?

Sreemaha
Sreemaha
Updated on 15-Mar-2026 364 Views

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 More

How to write PHP script to fetch data, based on some conditions, from MySQL table?

varma
varma
Updated on 15-Mar-2026 807 Views

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 More

Which PHP function is used to release cursor memory associated with MySQL result?

varun
varun
Updated on 15-Mar-2026 252 Views

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 More

How 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?

Prabhas
Prabhas
Updated on 15-Mar-2026 790 Views

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 More

How can we display all the records from MySQL table with the help of PHP script?

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 1K+ Views

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

Which PHP functions are used in the PHP script to fetch data from an existing MySQL table?

Nikitha N
Nikitha N
Updated on 15-Mar-2026 235 Views

PHP provides several functions to fetch data from an existing MySQL table. The most commonly used functions are mysql_query() for executing SQL queries and mysql_fetch_array() for retrieving rows from the result set. mysql_query() Function This function executes an SQL query against a MySQL database and returns a result resource on success or FALSE on failure ? Syntax bool mysql_query( sql, connection ); Parameters Parameter Description sql Required − SQL query to fetch data from an existing MySQL table connection Optional − MySQL connection resource. If not ...

Read More

How can we delete an existing MySQL table by using PHP script?

Nitya Raut
Nitya Raut
Updated on 15-Mar-2026 291 Views

In PHP, you can delete an existing MySQL table using the DROP TABLE SQL statement with PHP's database connection functions. Modern PHP applications should use MySQLi or PDO instead of the deprecated mysql_* functions. Using MySQLi (Procedural) Here's how to delete a MySQL table using MySQLi with proper error handling ? Using PDO PDO provides a more secure and object-oriented approach ? With Safety Check It's good practice to check if the table exists before attempting to delete it ? Key ...

Read More
Showing 11–20 of 3,547 articles
« Prev 1 2 3 4 5 355 Next »
Advertisements