Found 1046 Articles for PHP

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

286 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

4K+ 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

280 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

230 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

215 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

583 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

How can we write PHP script to release cursor memory associated with MySQL result?

usharani
Updated on 22-Jun-2020 14:03:17

195 Views

As we know that PHP uses the msql_free_result() function to release cursor memory associated with MySQL result. To illustrate it we are having the following example −ExampleIn this example, we are writing the following PHP script that will release the memory after fetching the records from a table named ‘Tutorials_tbl’.

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

varun
Updated on 22-Jun-2020 14:06:01

167 Views

PHP uses mysql_free_result() function to release the cursor memory associated with MySQL result. It returns no value.SyntaxMysql_free_result(result);Followings are the parameters used in this function −Sr.NoParameter & Description1ResultRequired- Specifies a result set identifier returned by mysql_query(), mysql_store_result() or mysql_use_result()

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
Updated on 22-Jun-2020 13:39:30

548 Views

The function mysql_fetch_array() will return an array with the numeric index if we use the constant MYSQL_NUM as the second argument to it. To illustrate it we are having the following example −ExampleIn this example, we are fetching all the records from a table named ‘Tutorials_tbl’ with the help of PHP script that uses mysql_fetch_array() function using MYSQL_NUM as the second argument in the following example −

How can we display all the records from MySQL table with the help of PHP script that uses mysql_fetch_assoc() function?

seetha
Updated on 22-Jun-2020 13:57:51

345 Views

To illustrate this we are fetching all the records from a table named ‘Tutorials_tbl’ with the help of PHP script that uses mysql_fetch_assoc() function in the following example −Example

Advertisements