|
What the script does -
The query selects all records from the 'names' table that have 'Chuck' in the NameFirst. We already knew there was only one - but the call to the mysql_num_rows function confirms it.
When the query runs, the retrieved record is stored in the $result variable when $query is processed by the call to the mysql_query
function. We display the number of records using the $num_results variable in the 'echo' statement
We use the mysql_fetch_assoc
function to create an array in a variable named '$row'. There are other functions available that can retrieve a single row from $result, but we use mysql_fetch_assoc for consistency, since we will frequently be retrieving and using multiple records. We use an associative array rather than a numeric array so we can refer to columns by their name instead of a number.
|