Found 1060 Articles for PHP

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

Priya Pallavi
Updated on 22-Jun-2020 14:31:14

2K+ Views

We can write the following PHP script to get the list of available MySQL databases −Example

How can we write PHP script to count the affected rows by MySQL query?

vanithasree
Updated on 22-Jun-2020 14:30:45

392 Views

PHP uses mysql_affected_rows( ) function to find out how many rows a query changed. To illustrate it we are having the following example −Example           Rows affected by query                  

Which PHP function is used to give the number of rows affected by MySQL query?

Nikitha N
Updated on 22-Jun-2020 14:08:04

222 Views

PHP uses mysql_affected_rows( ) function to find out how many rows a query changed. This function basically returns the number of affected rows in the previous SELECT, INSERT, UPDATE, REPLACE, or DELETE query. Return of an integer > 0 indicates the number of rows affected, 0 indicates that no records were affected and -1 indicates that the query returned an error. Its syntax is as follows −Syntaxmysql_affected_rows( connection );Followings are the parameters used in this function −S. No.Parameter & Description1.ConnectionRequired – Specifies the MySQL connection to use

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

radhakrishna
Updated on 22-Jun-2020 14:08:57

2K+ Views

As we know that PHP provides us the function named mysql_query() to create a MySQL table. Similarly, we can use mysql_query() function to create MySQL temporary table. To illustrate this, we are using the following example −ExampleIn this example, we are creating a temporary table named ‘SalesSummary’ with the help of PHP script in the following example −           Creating MySQL Temporary Tables              

How can we handle NULL values stored in a MySQL table by using PHP script?

Srinivas Gorla
Updated on 22-Jun-2020 14:09:52

389 Views

We can use the if...else condition in PHP script to prepare a query based on the NULL value. To illustrate it we are having the following example −ExampleIn this example, we are using the table named ‘tcount_tbl’ having the following data −mysql> SELECT * from tcount_tbl; +-----------------+----------------+ | tutorial_author | tutorial_count | +-----------------+----------------+ |      mahran     |       20       | |      mahnaz     |      NULL      | |       Jen       |      NULL      | |      Gill       |       20       | +-----------------+----------------+ 4 rows in set (0.00 sec)Now, the following is a PHP script that takes the value of ‘tutorial_count’ from outside and compares it with the value available in the field.

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

mkotla
Updated on 22-Jun-2020 14:11:18

5K+ Views

We can use the syntax of MySQL JOIN for joining two tables into the PHP function – mysql_query(). This function is used to execute the SQL command and later another PHP function – mysql_fetch_array() can be used to fetch all the selected data.To illustrate it we are having the following example −ExampleIn this example, we are using two MySQL tables which have the following data −mysql> SELECT * FROM tcount_tbl; +-----------------+----------------+ | tutorial_author | tutorial_count | +-----------------+----------------+ | mahran          |      20        | | mahnaz          |     ... Read More

How to write PHP script by using LIKE clause inside it to match the data from MySQL table?

Giri Raju
Updated on 22-Jun-2020 14:17:26

415 Views

We can use the similar syntax of the WHERE...LIKE clause into the PHP function – mysql_query(). This function is used to execute the SQL command and later another PHP function – mysql_fetch_array() can be used to fetch all the selected data if the WHERE...LIKE clause is used along with the SELECT command.But if the WHERE...LIKE clause is being used with the DELETE or UPDATE command, then no further PHP function call is required.To illustrate it we are having the following example −ExampleIn this example, we are writing a PHP script that will return all the records from the table named ‘tutorial_tbl’ ... Read More

How to write PHP script to delete data from an existing MySQL table?

Ankitha Reddy
Updated on 30-Jul-2019 22:30:21

379 Views

We can use the SQL DELETE command with or without the WHERE CLAUSE into the PHP function – mysql_query(). This function will execute the SQL command in a similar way it is executed at the mysql> prompt. To illustrate it we are having the following example − Example In this example, we are writing a PHP script to delete a record from MySQL table named ‘tutorial_tbl’ whose tutorial_id as 3.

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

Sreemaha
Updated on 22-Jun-2020 14:01:31

322 Views

We can use the SQL UPDATE command with or without the WHERE CLAUSE in the PHP function – mysql_query(). This function will execute the SQL command in a similar way it is executed at the mysql> prompt. To illustrate it we are having the following example −ExampleIn this example, we are writing a PHP script to update the field named tutorial_title for a record having turorial_id as 3.

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

varma
Updated on 22-Jun-2020 14:02:39

759 Views

If we want to fetch conditional data from MySQL table then we can write WHERE clause in SQL statement and use it with a PHP script. While writing the PHP script we can use PHP function mysql_query(). This function is used to execute the SQL command and later another PHP function mysql_fetch_array() can be used to fetch all the selected data. This function returns a row as an associative array, a numeric array, or both. This function returns FALSE if there are no more rows. To illustrate it we are having the following example −ExampleIn this example we are writing ... Read More

Advertisements