Alright so I have an innate fear of everything MySQL
Here's my table:
+----+-----------------+------+
| id | name | age |
+----+-----------------+------+
| 1 | Timmy Mellowman | 23 |
| 2 | Jeff Johnson | 18 |
+----+-----------------+------+
Here's my PHP code
(outside of connecting to the DB)
$raw = mysql_query("SELECT * FROM example") or die(mysql_error());
$row = mysql_fetch_array($raw);
echo "\n\n";
print_r($row);
So here's my output:
Array
(
[0] => 1
[id] => 1
[1] => Timmy Mellowman
[name] => Timmy Mellowman
[2] => 23
[age] => 23
)
Why is this the output? Double the name? Why is the the name set for both [1] and [name]?
And on the side is their a better way to use PHP with MySQL
mysql_
family of functions. As you seem to be learning how to use PHP, now would be a great time to switch to PDO or mysqli. – Charles Dec 23 '12 at 3:41mysql_fetch_array
function. The default, when you don't specify, is BOTH. – spencer7593 Dec 23 '12 at 3:41