/ Published in: PHP
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
<?php
/*
** AUTHOR - Ronnie Aarebrot.
** Script - Simple MySQL fetch array helper.
** WebSite - www.RonnieAarebrot.com
**
**
** Description
**
** This will return your mysql_fetch_array's into
** some readable / simple arrays to use. The array
** key will be the same name as used in your database columns.
**
** * HOW TO USE ? *
**
** $query = mysql_query("SELECT * FROM users");
** $array = sqlFetch($query);
** echo "<pre>";
** print_r($array);
** echo "</pre>";
**
*/
function sqlFetch($query) {
$y = 0;
$x = 0;
while($x < $numFields) {
$array[$y][$fieldName] = $row["$fieldName"];
$x++;
}
$y++;
$x = 0;
}
return $array;
}
/*
* OUTPUT EXAMPLE *
Array
(
[0] => Array
(
[id] => 1
[username] => roaa
[password] => 446bcd0025e013351288b5f7999434b42d40916c
[mail] => [email protected]
[sex] => male
)
[1] => Array
(
[id] => 2
[username] => fungirl
[password] => 446bcd0025e013351288b5f7999434b42d40916c
[mail] => [email protected]
[sex] => female
)
[2] => Array
(
[id] => 3
[username] => dem0ns
[password] => 446bcd0025e013351288b5f7999434b42d40916c
[mail] => [email protected]
[sex] => male
)
[3] => Array
(
[id] => 4
[username] => hell0
[password] => 446bcd0025e013351288b5f7999434b42d40916c
[mail] => [email protected]
[sex] => male
)
[4] => Array
(
[id] => 5
[username] => meddoo
[password] => 446bcd0025e013351288b5f7999434b42d40916c
[mail] => [email protected]
[sex] => female
)
)
*/
?>
Comments
 Subscribe to comments
                    Subscribe to comments
                
                