0

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 :(:'(:'(:'(:'(:'(:'(:'(:'(:'(

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by legends
0

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);
0

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);

Edited by legends: n/a

0

You can using this:

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

You can using this:

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

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.