|
|
|
<?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 | | | How to make sure a that $foo is from a cookie and not from the URI. Categories : PHP, Variables, Global Variables, Cookies | | | bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL, PHP, MySQL, Complete Programs, Databases | | | 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 | | | getting the name of the current script and query string Categories : PHP, Global Variables, Variables, URLs | | | PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Retrieve text from table and email to your e-
address in pipe delimited format. Categories : PHP, MySQL | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | | | a function that builds an HTML select list from any mysql table. Categories : PHP, MySQL, HTML and PHP | | | phpAds, a complete banner and ad management system with detailled tracking and stats. Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | color codes for positive and negative numbers Categories : PHP, MySQL, Databases, HTML | |
|
|
|