I have an html page with few <?php ?>
code snippets in it. In the first snippet I am connecting to a database and fetching data. Now I want to display that data later in some div
tags on my HTML page.
So, is the following the easiest way to do it? When I fetch the data from my database, I store them in an array which I define globally - I mean to be visible in other PHP code snippets on page, and then in those div tags I just print whatever elements of that array I want, like this: <div class="info"> <?php print "{$info[2]} ?> </div>
. Is this the correct and safe way to do this and how it's done, I mean how should I define this global array $info
?