[insert_php]
$webcodeurl = explode(‘?’,$_SERVER[‘REQUEST_URI’],2);
$con=mysqli_connect(“localhost”,”1009902_xy50386″,”,m,4xw@U16KB”,”1009902-climatesake1″);
//check connection
if(mysqli_connect_errno())
{
echo “Failed to connect to MySQL: ” . mysqli_connect_error();
}
$sqlquery = “SELECT a.WebCode, a.Location, a.TreeCode, a.CommonName, a.DBH, a.CW1, a.CW2, a.Height, a.Year, a.Comment, a.UTMN, a.UTME, a.Lat, a.Long, a.KgC, a.KgCO2, a.Webpages, b.ScientificName, b.OtherNames, b.Leaf, b.Flower, b.Fruit, b.Twig, b.Bark, b.Wood, b.Facts, b.Reference, b.Images, b.ImageDescription, b.spcode, c.Weblink, c.Logo, c.LogoDesc FROM treeinfo AS a JOIN speciesinfo AS b ON a.CommonName = b.CommonName JOIN locationinfo AS c ON a.Location = c.Location WHERE a.WebCode LIKE ‘$webcodeurl[1]’ ORDER BY a.Year DESC LIMIT 1”;
/*
if (mysqli_query($con, $sqlquery))
{
echo ‘this query works’;
}
else
{
echo “Error executing query: ” . mysql_error();
}
*/
$result = mysqli_query($con, $sqlquery);
while($row = mysqli_fetch_array($result))
{
echo ‘
‘ . $row[‘CommonName’] . ‘ (‘ . $row[‘ScientificName’] . ‘)
‘;
echo ”
“;
echo ”
“;
echo ‘Location: ‘ . $row[‘Location’] . ‘
‘;
echo ‘Lat, Long: ‘ . $row[‘Lat’] . ‘ ,’ . $row[‘Long’] . ‘
‘;
echo ‘TreeCode: ‘ . $row[‘TreeCode’] . ‘
‘;
echo ‘Diameter (DBH): ‘ . $row[‘DBH’] . ‘cm
‘;
echo ‘Last Year Modified: ‘ . $row[‘Year’] . ‘
‘;
echo ‘Carbon Stored in this Tree:‘;
if($row[‘KgC’] == 0)
{echo ‘ No Data
‘;
}
else
{echo ‘ ‘ . $row[‘KgC’] . ‘kg of C
‘;
}
echo ‘Equivalent CO2:‘;
if($row[‘KgCO2’] == 0)
{echo ‘ No Data
‘;
}
else
{echo ‘ ‘ . $row[‘KgCO2’] . ‘kg of C
‘;
}
$img_urls = explode(‘:-)’,$row[‘Images’]);
$img_dsc = explode(‘:-)’,$row[‘ImageDescription’]);
$i=0;
while($i<= (count($img_urls)-1))
{
echo ‘‘;
$i++;
}
echo ”
“;
echo ”
“;
echo ‘Common Name: ‘ . $row[‘CommonName’] . ‘
‘;
echo ‘Scientific Name: ‘ . $row[‘ScientificName’] . ‘
‘;
echo ‘Other Names: ‘ . $row[‘OtherNames’] . ‘
‘;
echo ‘
‘;
echo ‘Leaf: ‘ . $row[‘Leaf’] . ‘
‘;
echo ‘Flower: ‘ . $row[‘Flower’] . ‘
‘;
echo ‘Fruit: ‘ . $row[‘Fruit’] . ‘
‘;
echo ‘Twig: ‘ . $row[‘Twig’] . ‘
‘;
echo ‘Bark: ‘ . $row[‘Bark’] . ‘
‘;
echo ‘Wood: ‘ . $row[‘Wood’] . ‘
‘;
echo ‘
‘;
echo ‘Did you know?
‘;
$b=explode(‘:-)’,$row[‘Facts’]);
$z=0;
while($z<=(count($b)-1))
{
$item_nbr = $z+1;
echo ‘‘ . $item_nbr . ‘. ‘ . $b[$z] . ‘
‘;
$z++;
}
echo ‘
‘;
echo ‘
‘;
echo ‘Reference
‘;
$r1=explode(‘:-)’,$row[‘Reference’]);
$r2=0;
while($r2<=(count($r1)-1))
{
$item_nbr = $r2+1;
echo ‘‘ . $item_nbr . ‘. ‘ . $r1[$r2] . ‘
‘;
$r2++;
}
//loading the “Find More Trees” link
echo ‘
‘;
echo ‘
‘;
echo ‘‘;
echo ‘
‘;
echo ‘
‘;
//loading links to sponsors and location information.
$logo_urls = explode(‘:-)’,$row[‘Logo’]);
$logo_link = explode(‘:-)’,$row[‘Weblink’]);
$logo_desc = explode(‘:-)’,$row[‘LogoDesc’]);
$j=0;
while($j<= (count($logo_urls)-1))
{
echo ‘‘;
$j++;
}
}
[/insert_php]