evanct Posted June 30, 2009 Share Posted June 30, 2009 I'm trying to select multiple mysql rows and assign each one as an associative array to an array index. in other words something like this: Array = (0 => (('column1' => 'value1') ('column2' => 'value2')) (1 => (('column1' => 'value3') ('column2' => 'value4'))) Having some trouble with this, can anyone help? Link to comment https://forums.phpfreaks.com/topic/164199-assign-entire-sql-rows-to-an-array/ Share on other sites More sharing options...
corbin Posted June 30, 2009 Share Posted June 30, 2009 assume $q is returned from mysql_query(). $a = array(); while($row = mysql_fetch_assoc($q)) { $a[] = $row; } Link to comment https://forums.phpfreaks.com/topic/164199-assign-entire-sql-rows-to-an-array/#findComment-866160 Share on other sites More sharing options...
evanct Posted June 30, 2009 Author Share Posted June 30, 2009 Well I can't even see if that worked or not because I'm having another problem now: when i refresh the page it sits there loading for quite some time and then I get this: "Fatal error: Maximum execution time of 30 seconds exceeded in C:\Apache2\htdocs\fileservice\classes\database.php on line 170" the line it refers to is the mysql_query() line here: function getAlbums($user) { $sql="SELECT * FROM albums WHERE user_name='$user'"; $result=mysql_query($sql,$this->connection); return $result; } my queries have been working fine until now, I was just trying to figure out that original problem and suddenly I got this. the query shouldn't even take 30 seconds, the table it's selecting from is very small with only 2 rows of data. Link to comment https://forums.phpfreaks.com/topic/164199-assign-entire-sql-rows-to-an-array/#findComment-866170 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.