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 : Mimic ASPs GetRows function with PHP
Categories : PHP, Databases, MySQL
bastien koert
Date : Jan 28th 2005
Grade : 3 of 5 (graded 3 times)
Viewed : 7205
File : No file for this code example.
Images : No Images for this code example.
Search : More code by bastien koert
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

ASP(VBScript), from time to time, has some neat features. One is a function called GetRows, which pertains to the Recordset object. Its purpose is to pull the entire recordset into a 2d array and close the connection to free resources. This type of functionality can be quite useful in a high load environment. So I thought it would duplicate the functionality with PHP. So here it is...

<?php
function GetRows($handle)
{
/*
    This function emulates the ASP GetRows function. It creates a 2 dimensional
  array of the data set where the :

    1st dimension is the row number of the data
    2nd dimension are the data fields

    Returns a two dimensional array if there are record or false if no records
  come out of the query
*/

   
if (mysql_num_rows($handle)>0){

   
//initialize the array
     
$RsArray1   = array();

   
//loop thru the recordset
     
while ($rows = mysql_fetch_array($handle))
      {
             
$RsArray1[] = $rows;
      }
//wend
     
return $RsArray1;
    }else{
     
//no records in recordset so return false
     
return false;
    }
//end if
    //close the connection
 
mysql_close($handle);

}
//end function
?>



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
Invision Forums Latest Threads list
Categories : PHP, Miscellaneous, Databases, MySQL
Checks Date-Input from HTML-Forms and converts to YYYY-MM-DD Format for MySQL Date-Fields
Categories : MySQL, Date Time, PHP, Databases
Sort the results from a SELECT query (any number of columns) into an array automatically.
Categories : PHP, PHP Classes, Arrays, Databases, MySQL
Tropicalm Genetree Family (MySQL based family tree)
Categories : PHP, Interfaces, Databases, MySQL, Complete Programs
usercounter class
Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables
GroupIT Engine v1.00rc1
Categories : PHP, Content Management, MySQL, Databases
How to thread a list of messages in database and show it in a treelike structure
Categories : PHP, MySQL, Databases
mySQL/PHP/search with multientry form and table output with colored rows
Categories : PHP, Beginner Guides, MySQL, HTML and PHP, Databases
Email a user with out exposing email address
Categories : PHP, Databases, MySQL, Email
Creating thumbnails from MySQL Blobs online
Categories : PHP, MySQL, Graphics, HTML and PHP, Databases
Message of the Day - Random Message (Needs MySQL!)
Categories : Databases, HTML and PHP, PHP, MySQL
Inserting data to a MySQL Database using AJAX
Categories : AJAX, HTTP, PHP, Databases, MySQL
AJAX Application
Categories : PHP, AJAX, Databases, MySQL
 bastien koert wrote :1282
To add even more flexibility, you can specify the MYSQL_ASSOC to add the field index to the resulting array

while ($rows = mysql_fetch_array($handle, MYSQL_ASSOC))