Re: template logic problem
| From: | Martin Wickman | Date: | Mon, 13 May 2002 09:41:45 +0000 |
| Subject: | Re: template logic problem | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-97326@lists.php.net to get a copy of this message | ||
List Peters wrote:
<html> <body> navigation <?php include file depending on url?> <body> </html> In the include file I have all the code i need. My problem is that for one page in the site I need to display a image in the navigation bar that is referenced from a database. The database query happens in the included file which is below the navigation in the html - This means i cant reference the image file name because the query hasnt happened.Well, either write the sql code twice, or could break out all your database queries into functions which you then put in a php file (say db_funs.php). Now require("db_functions.php") at the top of your file and call the get_navbar_image () when you need it. You also need to require("db_functions.php") in the "include file depending on url" file. The general philisophy is thus to put all programming logic which you use more than once in separate functions which you include.