Ideally, you would have a class that handles the data and is instantiated when the data is retrieved and/or used for each record or set of records from the DB. The object created in this way, would then be passed from function to function as needed.
This thinking normally leads people to eventually using Object Relational Mapping software, which is specifically designed to handle moving data in and out of a database or other persistent(ish) storage. That said, understanding the purpose of ORMs requires some knowledge of Object Oriented Programming and the commonly used patterns of the paradigm, so researching OOP might be a better place to start looking for answers. A wikipedia search on these topics would be a good idea.
As a general rule, consider that computer systems are better(more testable, fixable, extensible, replaceable) when the individual parts are encapsulated(isolated) from one another. So by doing something in a global way(this goes well beyond just declaring something global) you are interconnecting parts of the system that probably don't need to be connected.
How this isolation is done and to what degree is determined by you and the type of system you are building. If you are just writing some simple test code or a simple prototype, you can abuse global space as much as you want since the code will never see the light of day(keyword here is simple). If you are building a simple script that helps generate a couple web pages and that script will never evolve into anything more then that, you still don't have to worry about the global space much. But once you move beyond the trivial, you really should start isolating the parts of the system, as it will give you much better code to work with down the road(meaning pretty much as soon as it is typed in and compiles)
The more complex a project becomes, the more isolated the parts should be, so that a change in one area doesn't 'ripple' through the entire system. This ripple could be looked at as having to change something in the code in a hundred places instead of just a few or in the resulting bugs that come up after the fact because not everything was changed over or changed correctly(Human error will always win out here).