<adoptable id="32">
<variation id="1" chance="2.0">
<age image="bone32.png" />
<age date="604800" image="puppy32a.png" />
<age date="1814400" image="adult32a.png" />
Nick wrote:If you made that last change I suggested (allowing them to grow by age or date), you should be using age="xxx" instead of date="xxx"(and the code I suggested would have age in days, not seconds).
<variation id="3" chance="2.0">
<age image="bone30.png" />
<age age="9" image="dogpuppy.png" />
<age age="22" image="dogadult.png" />
</variation>
<?php
//Tell the browser that we are sending it a PNG image to display
header("Content-Type: image/png");
require("adopttools.php");
$idofpet = $_GET['idp'];
$db2 = mysql_connect('mysql5.000webhost.com', 'a3459659_122195', 'password goes here');
if (!$db2) {
die('no connection possible: ' . mysql_error());
}
$x2 = mysql_select_db('a3459659_122195');
$sql2 = "SELECT ID,UNIX_TIMESTAMP(date),petID,varID FROM adoptables WHERE ID=$idofpet;";
$result2 = mysql_query($sql2) or die(mysql_error());
$row = mysql_fetch_row($result2);
//Find the variation with the given adoptable id ('a') and variation id ('v')
$variation=find_variation($row[2], $row[3]);
//Decide which of the ages we want to show for the adoptable
$pickedAge=NULL; //We'll store the age we eventually pick into the variable $pickedAge
/* Check the ages in order. The age we end up picking will be the last age
* in the file where the current date is after the 'date' attribute
*/
foreach ($variation->age as $age) {
if (!isset($age['date']) || isset($age['age']) && (time() - $row[1])/86400 >= $age['age'] || isset($age['date']) && time() > strtotime($age['date'])) {
$pickedAge=$age;
}
}
//Now that we've picked the age, display the image that that age uses
readfile($pickedAge['image']);
exit();
?>
if (!isset($age['date']) || isset($age['age']) && (time() - $row[1])/86400 >= $age['age'] || isset($age['date']) && time() > strtotime($age['date'])) {
if (!isset($age['date']) && !isset($age['age']) || isset($age['age']) && (time() - $row[1])/86400 >= $age['age'] || isset($age['date']) && time() > strtotime($age['date'])) {
Users browsing this forum: No registered users and 2 guests