PHP Programmer Code

With 28+ years programming experience I have found that by making and using templates and library utilities, I can be much more productive, and do a PHP MySql project in half the time. I also use standard variable names to increase my productivity. Below are a description of some of these.

Put library and config info in the library directory under the base directory.

the config file (pc_config.php) has specific info about the project.
the library file (pc_lib.php) does the initialization and has standard functions.

Php programmer guy Some of the library functin I created and use are:

DEBUG functions
     pc_debug([$var=''] [,$label='___']) display debug information
     	looks at config variable $c_debug to = "on" in pc_config.php.
     	Command line ?debug=on will also activate the debugger for the session (or "off" will stop it)
     	call like: 	pc_debug();  with no parameters will show session, request and cookie arrays
			pc_debug($varname,'$varname 123');     remember to use single quote, not double quote for label
			pc_debug($_SESSION,'$_SESSION[] 242');  I like to put the variable name and line number in label
			pc_debug($row,'$row[] 217');  To see the record (row) from the sql table just loaded

FORM functions
	pc_f_text($name,[$value=""]) display text box, with value if presented
	pc_f_radio($name,$value [,$default=""]) if $default = $value it is checked
	pc_f_check($name [,$default=""]) if checked, value = "yes"
	pc_f_select_sql($name,$sql [,$default=""]) displays dropdown select box from sql
	pc_f_select($name,$values [,$default=""] [,$displays=""]) values and displays are comma delimited
         if $default = $value it is selected , displays optional, different than values

SQL functions
     pc_query($sql [,$label])  does query and error reporting
     pc_sql_1field($field,$table,$where)  get just one field from db

DATE functions
     pc_ymd_mdy($MySQLDate) retury mm/dd/yyyy from yyyy/mm/dd entered (from MySql format)
     pc_mdy_ymd($MDYDate) returns yyyy/mm/dd from mm/dd/yyyy entered  (to MySql format)
Misc functions
     pc_dencr($text,$de [,$key2=""]) decrypt or encrypt "d" or "e", extra key2 optional
     pc_text2image($text) display image of the text, such as for email address
Php programmer guy When doing an SQL command, I load the variable $sql with the sql command and then call pc_query(), such as:
$sql="SELECT * from filex WHERE f_id = '$the_id'";
$result=pc_query($sql,143);
    -or-
$result=pc_query($sql,99143); // if label > 99000 will show debug (actual sql command)

Then I extract the results into array $row such as:
	    while($row =mysql_fetch_array($result,1)){
			echo $row['f_address'];
		}
All variables, tables and field names should be lower case. Use _ (underscore) to make it more readable.
EG. $this_is_a_variable rather than $ThisIsAVariable
Field names from a table should contain the first letter of the table name then underscore, such as
For table "customers", c_first_name, c_phone
Sometime a table will have the first letter the same as another table, then for the second table use the first 2 letters. Such as for table category use: ca_id, ca_title

An experienced expert PHP MySQL programmer has to be efficient to get the project done fast, correct and affordable.

For an experienced PHP programmer, click here

AddMe - Search Engine Optimization