Jump to content

mysql_fetch_array killing me a little..


rockinaway

Recommended Posts

I have some OOP code im working on and I have some interactions with the database. However, mysql_fetch_array fails to be working. Have I missed something?

class core 
{
var $array_batsmen = '';
var $array_bowlers = '';


	// Query to get batsmen
	function get_batsmen()
	{
		return $this->array_batsmen = mysql_query('SELECT id, name, ability, strength FROM wtw_players WHERE team_id = 1 ORDER BY id ASC');


	}	

	// Query to get bowlers
	function get_bowlers()
	{
		$this->array_bowlers = mysql_query('SELECT id, name, ability, strength FROM wtw_players WHERE team_id = 2');		
	}	  



	// Generate array of batsmen to be used
	function generateBatsmen()
	{
		while ($array = mysql_fetch_array($this->array_batsmen))
		{	

			echo $array['name'];

		}	


	}

}

 

The functions are called later normally, i've only included the necessary parts. Basically I have the var $array_batsmen which stores the mysql_query. This is then later used with a mysql_fetch_array to return names from the earlier query.

 

But nothing happens! It doesn't return anything (don't worry, I have a return later on). The loop just doesn't seem to work :/

 

Link to comment
https://forums.phpfreaks.com/topic/237105-mysql_fetch_array-killing-me-a-little/
Share on other sites

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.