PHP Fetch array function problem
I have a database with two tables.
One of the tables contains a string containing numbers from 0 to 10.
In PHP I do this:
$query = "SELECT ".$param." FROM issues WHERE ".$param." >=0";
$result = @mysql_query($query) or showError("query failed");
if (!($record = mysql_fetch_array($result))) return null;
return $record;
The $ param parameter contains the name of the string.
I kind of expected to get an array containing a number between 0 and 10, but instead I get an array with two elements:
array(
[0] = 0
[row_name] = 0
.
.
. // AND SO ON
)
What is it.
I have never worked with these functions before and www.php.net has no examples that really help ...
+1
source to share
3 answers
By default mysql_fetch_array returns both normal and associative arrays, so you can access the values by position ($ result [0]) or by name ($ result ['user_name']) ':
array mysql_fetch_array ( resource $result [, int $result_type ] )
result_type: The type of the array to get. It is persistent and can enter the following values: MYSQL_ASSOC, MYSQL_NUM and the default MYSQL_BOTH.
+1
source to share