|
|
|
<?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().
*/
?> |
|
| 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 | | | How to load a query result into a PHP Array Categories : PHP, Databases, Arrays, MySQL | | | dynamic table columns Categories : PHP, HTML and PHP, Arrays, Databases, MySQL | | | Function for retrieving MySQL enum values into a PHP array.
Categories : PHP, Databases, MySQL, Arrays | | | 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 | | | 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 | | | 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 | | | Simple conversion functions to change MySQL dates to arrays, arrays to MySQL dates.
Categories : PHP, Arrays, Date Time, Databases, MySQL | | | Displaying records of database in more than one page (paging) Categories : Databases, MySQL, PHP | | | 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 | | | Cut your MySQL Connections to 1 line of code Categories : PHP, Beginner Guides, Databases, MySQL | | | simple script to send emails via a html-form to different users Categories : Email, MySQL, PHP, Databases | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | |
|
|
|