Jump to content

assign entire sql rows to an array


evanct

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.