Nooby, pls help!

hi everyone.
last week I’ve started taken php lessons, but the teacher sucks
, and today he gave us a new php code but i didn’t understand it very well

so please can anyone explain it to me, with common language

public function get_all_records(){
	
	$result=mysql_query("select news_id,news_tittel from news");
	
	$arrdata[]=array();
	
	while($row=mysql_fetch_array($result)){
		
		$arrdata[]=$row;
		
		}
	
	  return $arrdata;
	
	}

Please be aware that the mysql_* extension is now deprecated as of the current version of PHP and will very likely be removed from the next 5.x version and will likely not be in PHP 6.x (when it eventually is released). You should migrate over to either the mysqli_* extension or to PDO. PDO is a better choice as it doesn’t tie you down so much to a particular database server software.

Hi AJoudh,

Welcome to the forum.

If you are having problems then try http://www.php.net then type in the right-hand seach box m[COLOR=#333333]ysql_query().

[/COLOR]A detailed explanation with not only the results but also many helpful contributor’s notes.

If there is anything specific on which you require further information please post another query.

Have fun

Besides mysql, does anyone have a problem setting an array with an empty key?

$arrdata[]=array();

I always set with the name.

$arrdata = array();

Not to sure about this “teacher”.

At best the code looks like an incomplete snippet.

“public” suggests it’s part of a class as does the fact the function has no connection to a resource shown

thx for the info, it’s new to me, :smiley:

Thank you i will look into that

didn’t know at all, this teacher really messed it up

sorry i didn’t upload the whole code, but we’ve included a php file that establish a connection to mysql server