I am trying to display objects for a reminders list with the following fields:
Title
Date Added
and a reminder image (a clock in my case)
Currently i display the object with the following code
class ReminderList{
private $data;
/* The constructor */
public function __construct($par){
if(is_array($par))
$this->data = $par;
}
public function __toString(){
$image = $this->data['image'];
// The string we return is outputted by the echo statement
return '
<li id="todo-'.$this->data['id'].'" class="todo">
<div>echo'<img src="'$image'">';</div>
<div class="title">'.$this->data['title'].'</div>
<div class="date">'.$this->data['date_time'].'</div>
<div class="actions">
<a href="#" class="editReminder">Edit</a>
<a href="#" class="deleteReminder">Delete</a>
</div>
</li>';
}
}
The fileds in the DB are
title
image (containing a path to the image, not a blob)
and date_time
When creating the object i have it writing the title, creating the time, and then input a path (images/reminder.png).
I get a Parse error: syntax error, unexpected T_STRING but thats from the way Im declaring the $image variable.
Any thoughts on the correct way to call an image path from a DB and plug it into an img src in php?
My apologies if this is unclear, ive been working with this problem a while
This line is definitely causing the parse error:
Change it to this: