getEnumVals.php
<?php
/*
* (c) 2006, D.E. Silvia, All rights reserved.
* This code is available for use for non-commercial purposes.
* Free to distribute as long as this copyright information remains intact.
* No modification is authorized. Please, refer bugs/enhancements to
* dsilvia@mchsi.com
*
*/
/*
*
* Function to return enum values from a MySQL database in a PHP array.
* Values can then be easily displayed for user choices, i.e., in an
* HTML form.
*
* Arguments:
* $host: database host, e.g., 'localhost'
* $user: database user
* $password: database password for the user
* $db: database to connect
* $table: database table to access
* $field: name of the field (column) containing the enum
* $sorted: boolean for sorting. default: return the array sorted
*
*/
function getEnumVals ( $host , $user , $password , $db , $table , $field , $sorted = true )
{
$rp = mysql_connect ( $host , $user , $password );
$dbConnect = mysql_select_db ( $db );
$result = mysql_query ( 'show columns from ' . $table . ';' );
while( $tuple = mysql_fetch_assoc ( $result ))
{
if( $tuple [ 'Field' ] == $field )
{
$types = $tuple [ 'Type' ];
$beginStr = strpos ( $types , "(" )+ 1 ;
$endStr = strpos ( $types , ")" );
$types = substr ( $types , $beginStr , $endStr - $beginStr );
$types = str_replace ( "'" , "" , $types );
$types = split ( ',' , $types );
if( $sorted )
sort ( $types );
break;
}
}
mysql_close ( $rp );
return( $types );
}
?>
Simple conversion functions to change MySQL dates to arrays, arrays to MySQL dates.
Categories : PHP , Arrays , Date Time , Databases , MySQL How to load a query result into a PHP Array Categories : PHP , Databases , Arrays , MySQL Sort the results from a SELECT query (any number of columns) into an array automatically. Categories : PHP , PHP Classes , Arrays , Databases , MySQL bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL , PHP , MySQL , Complete Programs , Databases This functions makes it easy to use session-variables known from ASP. With one Cookie the array "session" will save and restore from a db-record. In this version MySQL is used but it's should very easy to change Categories : PHP , Arrays , Cookies , MySQL , Databases Finds the median in an array of numbers - Can be used with a MySql database column read into an array Categories : PHP , Arrays , Databases , MySQL This simple function will take a few arguments and easily set a associative array for each column in a result from a MySQL query Categories : Databases , PHP , MySQL , Arrays This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. Categories : Databases , MySQL , Complete Programs , PHP , Databases dynamic table columns Categories : PHP , HTML and PHP , Arrays , Databases , MySQL create a grid out of <INPUT TYPE=TEXT> then saving to a database. Uses
a 'multi-dimension array', but not really as the array is just one big array
with the index of "[$i][$j]". Have a look at the code and you'll see what I
mean. Categories : PHP , MySQL , Arrays , Databases Specify your connection settings and create a link to a MySQL database. Categories : PHP , PHP Classes , Databases , MySQL , Beginner Guides [PHP5] aDB PDO LIKE Database Abstraction. Switch easily from one db server to another, strong errors management, manage transactions, queries preparation and more. Categories : PHP , PHP Classes , Databases , MS SQL Server , MySQL Paginator - a class that can help you to split MySQL database query result sets to pages. Categories : MySQL , Databases , HTML , PHP Warning: Unknown(): A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0 Categories : PHP , Sessions , Databases , MySQL mediaCat-GTK v2.0.0 - an mp3/cd/dvd cataloging utility written in php-gtk which interfaces with mysql and ms access (or db supported by PHP's Unified ODBC Functions) Categories : PHP , MySQL , MS Access , Utilities , Databases