WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Initialize global variables for every field in a table. This version requires that phplib is installed on your server.
Categories : Global Variables, MySQL, PHP, Variables Update Picture
Victor Font
Date : Aug 05th 1999
Grade : Be the 1st to grade this Code Example
Viewed : 11085
File : example.php3
Images : No Images for this code example.
Search : More code by Victor Font
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php

/* variable initialization

        will initialize a global variable for every field in a given table
        reduces coding later if a table structure changes

        written by Victor M. Font Jr.
        Abba Consulting group
        http://abba.fontlife.com
        this version requires that phplib is installed on your server
*/


        function initvar($varname, $value=null){
                global $$varname;
                if(!isset($$varname)){
                        if ($value == null){
                                $$varname = "";
                        }else{
                                $$varname = $value;
                        }
                }
        }

        $db = new DB_Example;
        
        // populate this array with the tables for which you are initializing variables
        $sTableList = array("table1","table2","table3","table4","table5");

        for ($n=0; $n<=(count($sTableList)-1); $n++){
                $results = $db->metadata($sTableList[$n], true);

                for ($i=0; $i<$results["num_fields"]; $i++){
                        /*
                         if you want to initialize variables for types other
                         than strings and numbers, you'll have to add your own
                         type in the switch statment below
                        */
                        switch ($results[$i]["type"]){
                                case "string":
                                        initvar($results[$i]["name"]);
                                        break;
                                case "int":
                                        initvar($results[$i]["name"],0);
                                        break;
                                case "blob":
                                        initvar($results[$i]["name"]);
                                        break;
                        }
                }
        }
?>



Initialize global variables for every field in a table. This is the generic version. It does not require phplib.
Categories : Global Variables, MySQL, PHP, Variables
getting the name of the current script and query string
Categories : PHP, Global Variables, Variables, URLs
bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager
Categories : MySQL, PHP, MySQL, Complete Programs, Databases
How to make sure a that $foo is from a cookie and not from the URI.
Categories : PHP, Variables, Global Variables, Cookies
Make old style (PHP3) scripts using GET, POST, COOKIE and File uploads (POST) compatible with PHP 4.2.0
Categories : PHP, HTML and PHP, Global Variables, Cookies, Variables
Global Dump Highlighted
Categories : PHP, Variables, Global Variables
Simple script to passing persistent and growing array between recalls of one page (manipulate little stack).
Categories : Arrays, Global Variables, PHP, HTML and PHP, Variables
Pageinfo: Array containing page URI, page query string (parameters), request method (GET or POST) and the complete URI
Categories : Variables, PHP Options and Info, Arrays, URLs, PHP
Simple db results paging example
Categories : PHP, MySQL, Databases, Form Processing
A Complete table(ADD,EDIT,VIEW,DELETE) management System PHP,MYSQL, JAVASCRIPT
Categories : PHP, MySQL, Java Script, Databases
Convert a File database into MySQL
Categories : PHP, Filesystem, Databases, MySQL, Beginner Guides
for each record, do this to the first record, and do that to any subsequent record
Categories : PHP, Databases, MySQL, Beginner Guides
Current Page's URL using PHP
Categories : PHP, Beginner Guides, Global Variables
DBXML- A Class to backup databases in XML Format using web interface
Categories : PHP, PHP Classes, Databases, MySQL, XML
Dynamically generated pop-ups (Select items)
Categories : PHP, HTML and PHP, MySQL, Databases