I need to know how to pass the data's from database to a constructor like this

"Jungle Book" => new Book("Jungle Book", "R. Kipling", "A classic book."),
"Moonwalker" => new Book("Moonwalker", "J. Walker", ""),
"PHP for Dummies" => new Book("PHP for Dummies", "Some Smart Guy", "")


my coding is

$data = mysql_query("SELECT * FROM books")  or die(mysql_error()); 
 while($info = mysql_fetch_array( $data )) 
 { 

$title=$info['title'];
$Author =$info['Author'];
$Description=$info['Description'];
$info['title'];=> new Book ($title,$Author,$Description);

 }

but it's showing error like this

Parse error: syntax error, unexpected T_DOUBLE_ARROW in /opt/lampp/htdocs/mvc/model/Model.php on line 29

i dono how to do can anyone suggest me how to implement this concept r solving this error :(:'(:'(:'(:'(:'(:'(:'(:'(:'(

Your error in

$info['title'];=> new Book ($title,$Author,$Description);

line. What do you want with it?

May be...:

$obj = new Book ($title,$Author,$Description);

Your error in

$info['title'];=> new Book ($title,$Author,$Description);

line. What do you want with it?

May be...:

$obj = new Book ($title,$Author,$Description);

i need the book title as the object name for the class book tat's y i added like that the constructor is book()
as i said already i need like this

Jungle Book" => new Book("Jungle Book", "R. Kipling", "A classic book."),

here the jungle book is the title which should be same as the object name and the value passed in the object

even i do like this it's showing error

$title=$info['title']; 
$title=> new Book ($title,$Author,$Description);

You can using this:

$title=$info['title']; 
$$title= new Book ($title,$Author,$Description);

You can using this:

$title=$info['title']; 
$$title= new Book ($title,$Author,$Description);

but the problem is i can't able to return it :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.