|
|
$TablePartsDrawn = 1;
$server = 'localhost';
$database = "DinosaurZdata";
$user = "root";
$pass = "KGte49a7";
if ($FirstLetter) { // Visitor has selected an intial letter. See what Dinos start with the letter
$conect = 0; // Try for a database connection (PHP times out after 30 seconds)
while(!$conect) { // conect will be non-zero on a successful connection
$conect = @mysql_connect($server, $user, $pass);
}
if ($FirstLetter=="WithPic")
$query = "select Dinos.DinoName from Dinos left join DinoPics on DinoPics.DinoId=Dinos.DinoId where DinoPics.PictureLocation is NOT NULL order by DinoName";
else
$query = "SELECT DinoName from Dinos LEFT JOIN DinoPics on DinoPics.DinoId=Dinos.DinoId where DinoName like \"$FirstLetter\"order by DinoName";
$result = @mysql_db_query($database, $query);
if ($result) {
echo "";
echo " | \n";
echo " | ";
echo " ";
echo " ";
$TablePartsDrawn +=1;
if (isset($ThisDino)) {
$conect = 0;
while(!$conect) { // Make sure still connected to DB, if not, attempt to reconnect to DB.
$conect = @mysql_connect($server, $user, $pass);
}
$query = "SELECT Dinos.DinoId, DinoName, DinoClass, Weight, WeightUnits, Length, LengthUnits, BeginTimeLine, EndTimeLine, Dinos.MeatOrPlant as EatsWhat, MeatOrPlant.Name as FoodGroup, DiscDate, DiscName, MapCo.name as Country, MapCo.x as MapX, MapCo.y as MapY, DinoPics.PictureLocation as PicLoc, DinoFossil.PictureLocation as FossilLoc, DinoText.Description as DinoDesc FROM Dinos LEFT JOIN MeatOrPlant on Dinos.MeatOrPlant=MeatOrPlant.ID LEFT JOIN DinoLocations on Dinos.DinoId=DinoLocations.DinoId LEFT JOIN MapCo on DinoLocations.cid=MapCo.cid LEFT JOIN DinoPics on DinoPics.DinoId=Dinos.DinoId LEFT JOIN DinoFossil on DinoFossil.DinoId=Dinos.DinoId LEFT JOIN DinoText on DinoText.DinoId=Dinos.DinoId WHERE DinoName = '$ThisDino' order by DinoId, DinoLocations.cid";
$result = @mysql_db_query($database, $query);
// Initialize the variable that checks for duplicate entries, and other one-time initializations.
$PreviousDinoId = "";
$TimeLinePixels = 183;
$Counter = 0;
$CountryArray[0] = "";
$PreviousCountry = "";
$MapXSize = 268; // X Dimension in pixels of Map picture
$MapXScale = 100; // X at 100% == 100 data points
$DotXWidth = 6; // Width of Dot.gif = 6 pixels
$HalfDotXSize= 3; // 1/2 of X Dot.gif width = 6/2 pixels
$MapYSize = 156; // Y Dimension in pixels of Map picture
$MapYScale= 100; // Y at 100% == 100 data points
$DotYHeight = 6; // Height of Dot.gif = 6 pixels
$HalfDotYSize= 3; // 1/2 of Y Dot.gif height = 6/2 pixels
if ($result) {
$TablePartsDrawn +=1;
while ($r = mysql_fetch_array($result)) {
$DinoId = $r["DinoId"];
$DinoName = $r["DinoName"];
$DinoClass = $r["DinoClass"];
$MapId = $r["MapId"];
$Weight = $r["Weight"];
$WeightUnits = $r["WeightUnits"];
$Length = $r["Length"];
$LengthUnits = $r["LengthUnits"];
$BeginTimeLine = $r["BeginTimeLine"];
$EndTimeLine = $r["EndTimeLine"];
$MeatOrPlant = $r["FoodGroup"];
$Country = $r["Country"];
$MapX = $r["MapX"];
$MapY = $r["MapY"];
$DiscDate = $r["DiscDate"];
$DiscName = $r["DiscName"];
$Pic = $r["PicLoc"];
$Fossil = $r["FossilLoc"];
$DinoDescription = $r["DinoDesc"];
if ($DinoId != $PreviousDinoId) {
$Left = $BeginTimeLine;
$Mid = $EndTimeLine - $BeginTimeLine;
$Right = $TimeLinePixels - $EndTimeLine;
$Counter = 0;
$CountryArray[$Counter] = $Country;
}
$CountryArray[$Counter] = $Country;
// X position is (MapX * 256 / 200 ) - 1/2 Dot size
$MapXArray[$Counter] = (($MapX * $MapXSize) / $MapXScale) - $HalfDotXSize;
// Y position is (MapY * 156 / 100 ) - 1/2 Dot size
$MapYArray[$Counter] = (($MapY * $MapYSize) / $MapYScale) - $HalfDotYSize;
$Counter += 1;
// Remember what Dino we just printed, cause we don't want to print it more than once.
$PreviousDinoId = $DinoId;
} // end of while
// Now do some clean up for missing data - use defaults
if ($Pic == "")
$Pic = "dino_pics/egg.gif";
if ($Fossil == "")
$Fossil = "fossil_pics/tooth.gif";
if ($DinoDescription == "")
$DinoDescription = "A detailed description of this dinosaur is not available at this time.";
// We have all of the data. Now do some special processing to show/hide variable number of map dots.
if ($Counter == 1) {
$HideDots = "'dot12','','hide'";
$ShowDots = "'dot12','','show'";
} else {
if ($Counter == 2) {
$HideDots = "'dot12','','hide','dot13','','hide'";
$ShowDots = "'dot12','','show','dot13','','show'";
} else {
if ($Counter == 3) {
$HideDots = "'dot12','','hide','dot13','','hide','dot14','','hide'";
$ShowDots = "'dot12','','show','dot13','','show','dot14','','show'";
} else {
if ($Counter == 4){
$HideDots = "'dot12','','hide','dot13','','hide','dot14','','hide', 'dot15','','hide'";
$ShowDots = "'dot12','','show','dot13','','show','dot14','','show', 'dot15','','show'";
} else {
$HideDots = "'dot12','','hide','dot13','','hide','dot14','','hide', 'dot15','','hide','dot16','','hide'";
$ShowDots = "'dot12','','show','dot13','','show','dot14','','show', 'dot15','','show','dot16','','show'";
} } } }
// Now print out the HTML, with the dino information embedded.
// Start Fossil
echo "\n";
echo "\n";
echo "\n");
// End of Fossil
//Start Dino
echo "\n";
echo "\n";
echo "\n");
// End of Dino
// Start of Map
echo "\n";
echo "\n";
echo "\n\n";
echo " \n";
echo "\n";
// Position the Map Dots over the Map
echo "\n\n";
echo "  ";
$tmp = 1;
$DotId = 12; // Starting DIV id for the Map Dots
while ($tmp <= $Counter) {
if (($MapXArray[$tmp] != 0) || ($MapYArray[$tmp] != 0 )) {
$DotId = $tmp+12;
echo "\n\n";
echo "  ";
}
$tmp = $tmp+1;
}
echo " | \n";
// End of Map Dots
printf(" | \n");
// End of Map
// Start of Description
echo "\n";
echo "\n";
echo "\n\n";
echo " | ";
echo " $DinoDescription | \n";
printf(" | \n");
// End of Description
echo "";
} // end of if ($result)
else { // Dino was selected, but then not found! Oops.
echo "Error: System problem, Can't find the dino in table. Please report this problem so we can fix it.";
}
} // End of if ($ThisDino)
if ($result)
mysql_free_result($result);
} // end if ($result)
else {
echo "Error: No DinoNames starting with this letter";
}
} // end of if(ThisDino)
if ($TablePartsDrawn == 1) { // No 2nd DinoName selection table, so insert just a blank space
echo " | ";
echo " |  | ";
echo "
";
echo "