The query is
$q1 = "SELECT * from `event` ORDER BY `upload_date` DESC";
This is the function
function display_content($r, $dis){
foreach($r as $part) {
$dis .= '<br /><div id="event_box">';
$dis .= '<div id="event_name"><a href = " http://'.$part['link'].'" target="_blank"> '.$part['name'].'</a></div>';
$dis .= '<div id="start_date"><b>From: </b>'.$part['start_date'].' </div>';
$dis .= '<div id="end_date"><b>Until: </b>'.$part['end_date'].' </div>';
$dis .= '<div id="event_link"><b>Link: </b><a href = " http://'.$part['link'].'" target="_blank">Event Website</a></div>';
$dis .= '<div id="event_venue"><b>Venue: </b>'.$part['venue'].' </div>';
$a = array(854, 480);
$b = array(300, 300);
$str = $part['embed_code'];
$partVideo = str_replace($a, $b, $str);
$dis .= '<div id="event_video"> '.$partVideo.' </div>';
$dis .= '<div id="event_image"><a href = " http://'.$part['link'].'" target="_blank"><img src = "data:image;base64, '.$part['image'].'"';
$dis .= 'alt = "'.$part['name'].'"></a></div>';
$dis .= '<div id="details"> '.$part['details'].'<br /><br />';
$dis .= '<button class="share2 btn-primary s_twitter">Tweet!</button>  ';
$dis .= '<button class="share2 btn-primary s_facebook">Share on Facebook!</button></div>';
$dis .= '</div>';
$dis .= '<br />';
}
echo $dis;
} // close function display content
Later on I call
display_content($r1, $display);
Only the first instance (entry) of an event from the database appears, and it appears fine (name, venue, details etc), but all the other event entries do not appear at all. Like they are 'blocked' maybe.
However, they all appear fine if I remove the line
$dis .= '<div id="event_video"> '.$partVideo.' </div>';
Entries either have a
$dis .= '<div id="event_image"><a href = " http://'.$part['link'].'" target="_blank"><img src = "data:image;base64, '.$part['image'].'"';
$dis .= 'alt = "'.$part['name'].'"></a></div>';
or a
$dis .= '<div id="event_video"> '.$partVideo.' </div>';
'$dis' or what '$dis' represents in the function is defined/instantiated ($dis = '';) outside of the function so should be a global variable.
What is going on and how can I fix it?
I know that they don't all have the same image / video information, which probably means I should normalise my database better (these entries are NULL in the database until I fill them), but shouldn't they all appear / print on screen anyhow?
Why is only the first event appearing?
Thanks!
