So I am trying to get my php code to load better on the div so that the parent doesn't refresh. And I have a code in there so far but it doesn't seem like it wants to work..
any one know what's wrong
index.php
<?php
include("../connect.php");
include("head.php");
?>
<center><table class="content">
<tr><td><div id="inventory">
<h3>Inventory</h3>
<p>*Double click to Equip/Unequip<br>*Red=Equipped</p>
<?php include("inventory.php"); ?>
<hr>
<p>News: This game is in beta stage as you can see and everything is a bit basic. No worries. I am working on making the game much more better including graphics and such. Your Admin at Jez-Your Productions!</p>
</div></td><td>
<h3>Character Info.</h3>
<div id="charinfo">
<?php include("character.php"); ?>
</div><br><hr>
<div id="location">
<h3>Location</h3>
</div></td><td>
<div id="stats">
<h3>Stats</h3>
<?php include("stats.php"); ?><br>
<hr>
<form>
<select id="menu" onchange="go()">
<option>--Navigate--</option>
<option value="hospital.php">Hospital</option>
</select>
</form>
</div></td></tr>
</table>
<div id="fightframe"><?php include("Fight/index.php"); ?></div>//the fram that should get reloaded
<?php include("Chat/index.php"); ?>
</center>
Fight/index.php
<hr>
<LINK REL=StyleSheet HREF="../style.css" TYPE="text/css" MEDIA=screen>
<script type="text/javascript" src="../javascript.js"></script>
<?php
include("../../connect.php");
include("functions.php");
if(!isset($_COOKIE['player_id']))
die('Please login.<br><a href=../../index.php>Go back</a>.');
$Player=$_COOKIE['player_id'];
$Query="SELECT * from Users where ID='$Player'";
$Query2=mysql_query($Query) or die("Could not get user stats.");
$User=mysql_fetch_array($Query2);
if($_COOKIE['password'] !=md5($User['Password']))
die('Your Password doesnt seem right for this account. <a href=../../index.php>go back</a>');
if(isset($_POST['fight'])){
if($User['Health']<=0){
print"Oh dear! You are <b><font color=red>dead</font></b>! Please visit the hospital to get recovered.";
exit();
}
$Monsters=$_POST['monsterfight'];
$MonsterQuery="SELECT * FROM Monsters WHERE Name='$Monsters'";
$MonsterQuery2=mysql_query($MonsterQuery) or die("Could not get user stats.");
$Monster=mysql_fetch_array($MonsterQuery2);
mysql_query("UPDATE Users SET LastFight='$Monster[ID]' WHERE ID='$Player'");
$monpow=$Monster['Power'];
if(isset($_POST['monsterhealth'])){
$monsterhealth=$_POST['monsterhealth'];
}else{
$monsterhealth=$monpow*rand(1,15);
}
if(isset($_POST['monsterenergy'])){
$monsterenergy=$_POST['monsterenergy'];
}else{
$monsterenergy=$monpow*rand(1,15);
}
$monsterstrength=$monpow*rand(1,5);
$monsterwisdom=$monpow*rand(1,5);
$monsterdefence=$monpow*rand(1,5);
$monsterdexterity=$monpow*rand(1,5);
$monsteraccuracy=$monpow*rand(1,5);
echo"You fight ".$Monsters.", with ".$monsterhealth." health.<br>";
if($monsterdexterity>=($User['Dexterity']*rand(1,5))){
print"<font color=red>The monster attacks faster!<br></font>";
takedamage($monsterstrength, $monsteraccuracy);
}else{
print"<font color=green>You attack the monster faster!<br></font>";
$monsterhealth=dealdamage($monsterhealth, $monsterdefence);
}
if($monsterhealth>=1){
print"<form method=post><input type=hidden name=monsterfight value=$Monsters><input type=hidden name=monsterhealth value=$monsterhealth><input type=hidden name=monsterenergy value=$monsterenergy><input type=submit value=\"Fight Again\" onclick=\"loadpage(Fight, fightframe);\" name=fight></form>";//function to refresh the frame.
}else{
print"<br>You win the battle!<br>";
reward($monpow);
if($User['EXP']>=$User['NextEXP']){
print"You gain a level!<br>";
levelup();
}
print"<form method=POST><input type=hidden name=monsterfight value=$Monsters><input onclick=\"javascript:loadpage(Fight, fightframe);\" type=submit value=\"Fight ".$Monsters." Again\" name=fight></form>";//function to refresh the frame.
}
}else{
$mob=mysql_query("SELECT * FROM Monsters ORDER BY Power");
print"<form method=POST><select name=monsterfight>";
if($User['LastFight']=="0"){
}else{
$Laster=mysql_fetch_array("SELECT * FROM Monsters WHERE ID='$User[LastFight]'");
print"<option value=".$Laster['Name'].">".$Laster['Name']." - ".$Laster['Power']." (Last Fight)</option>";
}
while($Monster=mysql_fetch_array($mob)){
print"<option value=".$Monster['Name'].">".$Monster['Name']." - ".$Monster['Power']."</option>";
}
print"</select><input type=submit onclick=\"javascript:loadpage(Fight, fightframe);\" name=fight value=Fight></form>";//function to refresh the frame.
}
?>
javascript.js
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""
function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}
function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}
function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
function go()
{
window.location=document.getElementById("menu").value;
}
Hope the comments are good enough to understand.