username,hp,ehp and inbattle
when a user goes to the page im coding it adds them intothe table it makes hp and ehp 100 and makes in battle 1
now i have just added a drop down menu with moves and a button
now i want the ehp to go down
but i am getting a white blank page heres my code
<?php
if (!ini_get('display_errors')) {
ini_set('display_errors', 1);
}
include('include/session.php');
if (!$session->logged_in) {
header("Location: login.php");
}
// this checks and increments the battle counter accordingly
$session->checkPageJumping(true);
// all the stuff at the top of the page
require('sections/new_pagehead.php');
// all the stuff on the left column of the page
include_once('sections/new_leftbar.php');
?>
<?php
$result = mysql_query("SELECT * FROM battle WHERE username='".$_SESSION['username']."'");
$num_rows = mysql_num_rows($result);
if($num_rows < 1) {
mysql_query("INSERT INTO battle (username,hp,ehp, inbattle) VALUES ('" . $_SESSION['username'] . "','100','100','1')") or die(mysql_error());
}
?>
<link rel="shortcut icon" href="/favicon2.gif" type="image/x-icon" />
<style type="text/css">
<!--
.style3 {font-size: 18px}
-->
</style>
<div id="mid_section">
<div class="mid_section_inner">
<div class="mid_box">
<div class="mid_box_title">Your Pokemon</div>
<?php
// show the user their pokemon
include_once('pokemon_level.php');
// end file include
?>
</div>
<div class="mid_box">
<div class="mid_box_title">Current Battle</div>
<table width="200" border="1">
<tr>
<td><span class="style3">Your Hp </span></td>
<td><span class="style3">There hp </span></td>
</tr>
<tr>
<td><?php
$connect = mysql_connect("localhost", "pokemont_shadow", "mypass");
$database = mysql_select_db("pokemont_pokemon", $connect);
$sql = "SELECT hp from battle WHERE username='".$_SESSION['username']."'";
$res = mysql_query($sql) or die('Invalid query: ' . mysql_error());
$val = mysql_fetch_array($res);
echo $val['hp'];
?></td>
<td><?php
$connect = mysql_connect("localhost", "pokemont_shadow", "mypass");
$database = mysql_select_db("pokemont_pokemon", $connect);
$sql = "SELECT ehp from battle WHERE username='".$_SESSION['username']."'";
$res = mysql_query($sql) or die('Invalid query: ' . mysql_error());
$val = mysql_fetch_array($res);
echo $val['ehp'];
?></td>
</tr>
</table>
<p><?php
$sql = mysql_query("SELECT username FROM battle WHERE username='".$_SESSION['username']."'");
$num = mysql_num_rows($sql);
echo $num
?> </p>
<p> </p>
<p><img src="/pokemon/<?php echo $pokemon->{ 'pok' . $_SESSION['current_pokemon']}['pokePIC']; ?>" width="107" height="102" />
</p>
<div align="right"><img src="pokemon/Shinnyregirock.png" width="80" height="80"></div>
<form name="myform" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<div align="center">
<p>
<select name="mydropdown">
<option value="Move1">Move1</option>
<option value="Move2">Move2</option>
<option value="Move3">Move3</option>
</select>
</p>
<p>
<input name="submit" type="submit" />
</p>
</div>
</form>
<?php
if (isset($_POST['teamname']) && $_POST['teamname'] != "") {
if ($results->inbattle == 1) {
$sql="UPDATE battle SET hp='"-10"' WHERE username='" . $_SESSION['username'] . "'";
?>
</p>
<table width="200" border="1">
<tr>
<td> </td>
</tr>
</table>
</div>
</div>
</div>
<?php
// all the stuff on the right column of the page
include_once('sections/new_rightbar.php');
// close everything down with a footer
require('sections/footer.php');
?>
This add the user to the table which works
$result = mysql_query("SELECT * FROM battle WHERE username='".$_SESSION['username']."'");
$num_rows = mysql_num_rows($result);
if($num_rows < 1) {
mysql_query("INSERT INTO battle (username,hp,ehp, inbattle) VALUES ('" . $_SESSION['username'] . "','100','100','1')") or die(mysql_error());
}
Then i use this to take so much away from the ehp
<form name="myform" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<div align="center">
<p>
<select name="mydropdown">
<option value="Move1">Move1</option>
<option value="Move2">Move2</option>
<option value="Move3">Move3</option>
</select>
</p>
<p>
<input name="submit" type="submit" />
</p>
</div>
</form>
<?php
if (isset($_POST['teamname']) && $_POST['teamname'] != "") {
if ($results->inbattle == 1) {
$sql="UPDATE battle SET hp='"-10"' WHERE username='" . $_SESSION['username'] . "'";
?>
but im getting a blank page

New Topic/Question
Reply



MultiQuote





|