Retrieving Query Results
In the preceding section of this chapter I discussed and demonstrated how to execute simple queries on a MySQL database. A simple query, as I’m calling it, could be defined as one that begins with INSERT, UPDATE, DELETE, or ALTER. What all four of these have in common is that they return no data, just an indication of their success. Conversely, a SELECT query generates information (i.e., it will return rows of records) that has to be handled by other PHP functions.
The primary tool for handling SELECT query results is mysql_fetch_array(), which takes the query result variable (that I’ve been calling $result) and returns one row of data at a time, in an array format. You’ll want to use this function within a loop that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access