<?php
$dbh = mysql_connect ("localhost", "ramygala_knygos", "Nuoma2007") or die ('Nepavyko prisijungti prie DB, nes ' . mysql_error());
$pa = mysql_select_db ("ramygala_testknygos",$dbh);
mysql_query("SET NAMES 'utf8'");
$sql = "SELECT kultura_tvarkarastis.*, b.id AS id2, b.link AS link2, b.name AS name2, b.g_link FROM kultura_tvarkarastis LEFT JOIN kultura_location AS b ON kultura_tvarkarastis.location_id = b.id WHERE kultura_tvarkarastis.date = '2010-07-05' ORDER BY date, hour";
$res = mysql_query($sql);
$bgcolor = "#FFFFFF";
$icon = "";
$l_link="";
$l_link0 ="";
$name_old="";
$check = true;
echo "<div><font face='Arial' size='2px'><table border='0' cellpading ='0' cellspacing = '0' width = '100%'><tr><td> </td><td><h2>Miesto šventė "Ramygalai - 640" liepos 5 dieną</h2></td></tr>";
$i =1;
while (($data = mysql_fetch_array($res, MYSQL_ASSOC)) && $i<=500){
//Nuorodos ir paveiksliuko kurimas Google maps nuorodai
if ($data['g_link'] <>"") {$icon = "<a href='".$data['g_link']."'target ='_blank' ><img src='images/globe_icon.gif' height ='12' width ='12' alt='GMaps link' border ='0'/></a>";}
//Nuorodos kurimas rengionio vietai
if ($data['name2']<>"" && $data['link2']<>""){$l_link="<a href='".$data['link2']." ' target ='_blank'>";$l_link0="</a>";$data['location']=$data['name2'];}
echo"<tr bgcolor=$bgcolor valing=top><b><td width ='40px' align='left' valign='top'>".substr($data['hour'], 0, 5)." </td><td width='489px'><b>Vieta: </b>$l_link".$data['location']." $l_link0 $icon </td></tr>";
//Tikrina ar yra renginio aprasymas, jei nera, nespausdina paskutines eilutes
if ($data['description'] <> "nera"){
echo "<tr bgcolor=$bgcolor valign='top'><td width ='40px'> </td><td width ='489px'>".$data['description']."</td></tr>";
}
else {
echo "<tr bgcolor=$bgcolor valign='top'><td width ='40px'> </td><td width ='489px'> </td></tr>";
}
$l_link ="";
$l_link0="";
$icon = "";
}
echo "</table></font></div>";
mysql_close($dbh);
echo "<p align=right><a href='index.php?option=com_content&task=view&id=247&Itemid=55'>Renginių tvarkaraštis</a></font></p>";
?>