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 : 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 Update Picture
Hans Anderson
Date : Jan 17th 1999
Grade : Be the 1st to grade this Code Example
Viewed : 7135
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Hans Anderson
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php
function setmysqlresults($resultpointer,$row = 0) {
$i=0;
$n=mysql_num_fields($resultpointer);
while($i<$n) {
$fieldname = mysql_field_name($resultpointer,$i);
$fieldresult = mysql_result($resultpointer,$row,$fieldname);
$hash[$fieldname] = $fieldresult;
$i++;
}
return $hash;
} // end setmysqlresults()

/*

usage:

$r = mysql_query("select Column1, Column2, Column3 from Table");
$i=0;
while(mysql_fetch_row($r)) {
$rs = setmysqlresults($r,$i);
print "$rs[Column1], $rs[Column2], $rs[Column3]\n";
$i++;
}

Using this function, you won't need to go through the lengthy assignment
of mysql_result() to variables.

To test for validity, use is_array(). If this function fails, it will
return a simple value. If it succeeds, it will be an associative array. For
more information on associative arrays, see the PHP3 manual for array().

*/

?>



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 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
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
Function for retrieving MySQL enum values into a PHP array.
Categories : PHP, Databases, MySQL, Arrays
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
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
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
Function to do live population of HTML's <Select> tag from a Table
Categories : PHP, MySQL, HTML and PHP, Databases
Automatically printing the contents of an sql table in MySQL.
Categories : MySQL, PHP, HTML and PHP, Databases
This script is a contact form between users of a website (kinda like the PM function on the forums)
Categories : PHP, Databases, MySQL, Regexps
PHP Transfer data from text file to Mysql Table
Categories : PHP, PHP Classes, Filesystem, Databases, MySQL
Alternating background color for HTML table rows
Categories : PHP, Databases, MySQL, HTML and PHP