Could anyone please assist me? I am developing a game and i've got a bit stuck.
On the link below, you'll hopefully see a date counter top right hand corner with a continue button just above it which when clicked skips the counter on a few days.
Thing is the counter skips/animates on a few days fine, but I have a problem that the counter defaults back to the current date when the page is refreshed.
And doesn't keep the current custom date, that you've skipped to. Additionally I am also trying to write/update the date to another PHP file called gamedate.php which I hope to use eventually as a save game feature.
So when you come back and load your game it will load the day you saved last from gamedate.php.
I have attached as to what I believe are probably the necessary files, hopefully one of you wonderful people will reply.
Should you require anything else please just ask. Thanks
<div id="tabscontainer"> <!-- tabs start -->
<ul class="tabs" persist="true">
<li><a href="#" rel="view1">Overview</a></li>
<li><a href="#" rel="view2">Profile</a></li>
<li><a href="#" rel="view3">News</a></li>
<li><a href="#" rel="view4">Notebook</a></li>
<li><a href="#" rel="view5">History</a></li>
<li><a href="#" rel="view6">Stats</a></li>
</ul>
<div class="tabcontents"> <!-- tabs content start -->
<div id="view1" class="tabcontent">
<div id="hm-inbox">
<h2 id="dateH2"></h2>
<script src="assets/js/hm-inbox.js" type="text/javascript"></script>
</div>
</div>
<div id="view2" class="tabcontent">
<b>Multiple Tab Contents</b>
<p>You can have multiple tab contents on the same page, with only one copy of the CSS and JavaScript files.</p>
</div>
<div id="view3" class="tabcontent">
<b>Bookmark Support</b>
<p>You can also open a tab or a bookmark from a link anywhere on the page.</p>
<p id="mark4">This is a paragraph with id="mark4".</p>
<p>By clicking the bookmark link at the bottom of this Tab Content, you will see me with this Tab Content panel being opened at the same time.</p>
</div>
<div id="view4" class="tabcontent">
<b>Opened by a link from another page</b>
<p>Link from another page can select a tab on the target page when loaded.</p>
</div>
</div> <!-- tabs content end -->
<br><br>
</div> <!-- tabs end -->
<!-- datecounter js start -->
<script type="text/javascript">
var futureDay = new Date(<?php echo $gamedate; ?>);
var myCounter = null;
var timerId = null;
function loadCounter(){
myCounter = [
new Counter("my_counter_1",
{
digitsNumber : 1,
direction : Counter.ScrollDirection.Upwards,
I would use session, so in your code just put this
PHP Code:
<?php
session_start();
$newdate = date ("Y,n,j,0,0,0");
require('users/gamedate.php');
$_SESSION['gamedate'] = $newdate;
Then wherever you reference your $gamedate varaible in your current code, check if the session is set for gamedate and if so use the stored session data instead
PHP Code:
if (isset($_SESSION['gamedate'])) {
// Do whatever here to use the session data
} else {
// Use original date (i.e. the date before it has been changed by the user)
}
Bookmarks