1) i just reload the page after the 5 sec - now i see my button and the level is increased also the time in the DB is set to 0
2)after realoding a second time - the building starts to increase its level without me clicking the button..
Hers the Code:
Code: Select all
Metallmine: <?php echo ausgabeplanets('ress_building1'); ?><br>
<?php if (ausgabeplanets('ress_building1_time') > 0)
{
?> Restbauzeit: <?php $rest=ausgabeplanets('ress_building1_time') - time(); echo $rest; ?> <?php
}
else
{ ?>
<form action="#" method="post">
<input type="submit" value="Metallmine ausbauen" name="bau" >
</form>
<?php echo "Testtext1"; ?>
<?php } ?>Code: Select all
<?php
include ("connect.php");
include ("calculations.php");
//DB anbindung
//Funktion für Datenausgabe von planets tabelle
function ausgabeplanets($var)
{
$abfrageplanets = mysql_query('SELECT ' . $var . " FROM planets WHERE id = '".$_SESSION['uid']."'");
$row = mysql_fetch_object($abfrageplanets);
return $row->$var;
}
//----------------------------------------------------------------------------------------------------------
$zeit = time();
function gebbau()
{
if(ausgabeplanets('ress_building1_time') == 0)
{
$zeit=time() + 5;
mysql_query("UPDATE planets SET ress_building1_time = $zeit WHERE id ='".$_SESSION['uid']."'");
}
if (isset($_POST['bau']))
{
echo gebbau();
}
}
//----------------------------------------------------------------------------------------------------------
//Function überprüft ob gebäude fertig ist
function gebfertig_rohstoff1()
{
if(ausgabeplanets('ress_building1_time')>0)
//Prüfen ob es eine Zeit gibt spricht weil sonst 1940 sek anzahl stehen würde
{
$rest = ausgabeplanets('ress_building1_time') - time();
if($rest < 0)
{
mysql_query("UPDATE planets SET ress_building1 = ress_building1 + 1 , ress_building1_time = 0 WHERE id ='".$_SESSION['uid']."'");
}
}
}