Title : selecting multiple rows.
Version: 1.0.0
Author: Mian Shafiq-ur-Rehman
Email : gurru@phpgurru.com
Mess : rehmanms@hotmail.com
Website: www.phpgurru.com
If you want to select multiple rows from a mySql Table, you have no need to worry about. This function will do every thing. All you have to do is to pass an SQL query to this function and it will return a 2D array.
<?php
function selectMultiRows ( $query )
{
if((@ $result = mysql_query ( $query ))== FALSE )
{
echo "<strong>Error in your query:</strong> <br> $query " ;
}
else
{
$count = 0 ;
$data = array();
while ( $row = mysql_fetch_array ( $result ))
{
$data [ $count ] = $row ;
$count ++;
}
return $data ;
}
}
?>
Usage Example
<?php
$query = "select * from Users" ;
$returnedData = selectMultiRows ( $query );
$totalRecords = count ( $returnedData );
for( $i = 0 ; $i < $totalRecords ; $i ++)
{
echo $returnedData [ $i ][ "username" ] . "<br>" ;
}
?>
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 MyOrgBook - Online Organizer written in PHP & MySql. Includes online contacts, todo, calendar, update, delete, insert, multi-user interface. Categories : PHP , MySQL , Calendar , PDAs and Organizers , Databases Simple usersOnline class - keep track of how many users are online on your site Categories : PHP , PHP Classes , Databases , MySQL Function to check connection to MySQL and redirect to an error page if an error occurs Categories : MySQL , PHP , Debugging , Databases MySQL Web Interface Categories : MySQL , Databases , PHP A PHP useradmin for MySQL. Uploading is easy. The only thing you need is
PHP and MySQL installed! Categories : MySQL , Databases , PHP , HTML and PHP PostGreSQL and MySQL 2 in 1 db Manager Categories : PHP , PHP Classes , Databases , PostgreSQL , MySQL AJAX Data Grid System using php and mysql. A complete login system with the ability to display data in a grid using ajax. Add , update and delete the records without reloading the page. Categories : PHP , AJAX , Databases , MySQL , Java Script Loading Images to/from MySQL Categories : Databases , MySQL , PHP , Graphics Solution to those 'tell-a-friend' type email issues Categories : PHP , Email , Databases , MySQL PHP Object Example of the Perl DBI with MySQL Categories : PHP , PHP Classes , MySQL , Databases , Perl [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 Shopping Basket On-Line Ordering System. Categories : Complete Programs , MySQL , PHP , Ecommerce , Databases Simple function to return the number of days in a time span between 2 given dates. Categories : PHP , Date Time , MySQL , Databases
Olaf Lederer wrote : 1267
why not:
$query = "select * from Users";
$result = mysql_query ($query);
while ( $row = mysql_fetch_array($result)) {
echo $row[`username`];
}
what is the clou of this function ?
Olaf Lederer wrote : 1268
it`s late
clou = advantage
;-) (clou is dutch)