But if you’re starting out, you really should ditch myqsl calls and use mysqli or PDO instead. Above code assumes you’ve connected to the database somewhere, and obviously you’d want to check if the query returns something before continuing.
mysql_fetch_assoc returns results with an associative array (not numerical) while mysql_fetch_array returns both numerical and associative (but has options to choose one or the other too).
You ought to read this: http://www.php.net/manual/en/mysqlinfo.api.choosing.php and move away from procedural mysql_ calls ASAP. mysqli may be the easiest to move over to as it still allows procedural code or of course PDO for OOP-based.
just for an advice,you should not practice native mysql because it is deprecated,you should use PDO,…but if your project using native then you have no choice to continue it…but if you have chance to reverse the code to PDO it’s good.