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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.