answersLogoWhite

0


Best Answer

There are many factors that must be taken into consideration when looking to retrieve data from a database, such as 'what database management system do i posses/supported by my host?' in most cases people looking to retrieve data using php posses SQL database management systems such as MySQL in their control panel which can be used to create, delete and alter databases, along with creating multiuser access to the databases.

once the databases are created and their respected users are added and given their database privileges, one can begin adding and proccessing data to and from a database.

assuming that all the previous has been acheived and there is data in the database, below is a set of php/mysql functions that can process multiple rows of data in a database table.

$link = mysql_connect ("localhost", "USERNAME HERE", "PASSWORD HERE") or die (mysql_error());

$mysql_db = mysql_select_db ("DATABASE NAME") or die (mysql_error());

$db_search = mysql_query("SELECT * FROM `TABLE NAME`");

if (@mysql_num_rows($db_search) > 0) {

while($data = mysql_fetch_array($db_search)) {

}

}

first you connect to your host, then select the database, query a selected table, check for rows of data in the table, place the array of data into a variable, and do what you please with the data now contained within that variable.

for more information go to php.net/mysql

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

AnswerBot

3d ago

To retrieve data from a database in PHP, you can use SQL queries. First, establish a connection to the database using MySQLi or PDO. Then, use SELECT queries to fetch data from the database tables based on your requirements. Execute the query and fetch the results using appropriate functions like mysqli_fetch_assoc() or PDO fetch().

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you retrieve data from database in PHP?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you validate and retrieve data from database?

How do you validate and retrieve data from database?" How do you validate and retrieve data from database?"


What is a database in PHP?

Database = Where you save your data (ex: if a user fill your registration form, entered data should be saved somewhere, that's database) Usually in PHP we use MySQL Database.


How do retrieve data from database in c?

nbbmnbmn


How do you retrieve username and password from sql database to HTML web page?

You would need to use PHP


What database objects allows you to search for and retrieve data?

SQL queries allow you to search for and retrieve data from a database. By writing SELECT statements with specific criteria, you can search for information in tables and retrieve the results based on your query.


How do you retrieve values from database?

It depends on what database are you using. There are some ways in PHP but the most common of them are PHP native database driver and PDO. PHP native database driver is a collection of functions to communicate with a particular DBMS, they usually have the DBMS name prefixed in the function name. For example, driver functions for MySQL have mysql_* prefix.


Data conversion and loading in database?

By data conversion we mean the data is first processed. The data after processing is ready to store in database. And from the database we can retrieve it for our use.


How do you delete data from a MySQL database using PHP?

To delete data from your MySQL database you need to use the mysql_query() function. Please see the example below: <?php mysql_query("DELETE FROM table_name WHERE field_name = 44"); ?>


What is the select element?

To retrieve or modify data in the database query are used. There are four types of commands in SQL. Select command is data retrieval language command and is used to retrieve data from a database.In database there Four types of languages which contains various commands. Select command is the only command that is used for retrieval of data.


How do you retrieve auto increment id in PHP and MySQL?

When creating the MySQL database select "Auto-Increment" on the "Extras" bar.


How do you retrieve data from one MySQL table and create another MySQL table with the same data in it using PHP?

Execute a SELECT INTO statement on the mysql database: INSERT INTO destination_table (id, first_name, last_name) SELECT id, first_name, last_name from source_table;


What software allows the user to enter retrieve and update data in an organized and efficient manner?

Any application that lets you save and retrieve a file. My best guess is that you are looking for database as an answer.