<?php
		$selected = mssql_select_db('World00_Character', $mssqlhandle) or die ("Couldn't open database Account"); 
		$result=mssql_query('SELECT COUNT(sID) FROM tCharacter');
		list($charentries)=mssql_fetch_row($result);
?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td class="sitemenu"><strong>Edit Character</strong></td>
            </tr>
            <tr>
              <td class="sitemenu"><hr size="1" /></td>
            </tr>
            <tr>
              <td align="left" valign="top" class="sitemenu">
              
              
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="23%" align="left" valign="top" bgcolor="#333333" class="sitemenu">1. Step</td>
                </tr>
                <tr>
                  <td align="left" valign="top" class="sitemenu">
                  <form id="form1" name="form1" method="post" action="action.php?action=editchar">
                    <table width="100%" border="0" cellspacing="1" cellpadding="0">
                      <tr>
                        <td align="left" valign="top" class="sitemenu"><strong>Characters in Database:</strong> <?php echo $charentries; ?></td>
                      </tr>
                      <tr>
                        <td align="left" valign="top" bgcolor="#202020" class="sitemenu">Please   enter a Charactername</td>
                      </tr>
                      <tr>
                        <td align="left" valign="top" class="sitemenu">
                        <input type="text" name="searchchar" id="textfield" /> <input type="submit" name="editcharstep2" value="search" />
                        </td>
                      </tr>
                    </table>
                  </form>               
                  
                  </td>
                </tr>
              </table>
              
              
                <br />
 <?php
				if ($_SESSION['editcharstep'] == 2)
						{
							$selected = mssql_select_db('World00_Character', $mssqlhandle) or die ("Couldn't open database Account"); 
							$get_info = mssql_query("SELECT * FROM tCharacter WHERE (sID = '".$_SESSION['edit_char']."')");
							$row_info = mssql_fetch_array($get_info);	
?>
                
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="23%" align="left" valign="top" bgcolor="#333333" class="sitemenu">2. Step</td>
                  </tr>
                  <tr>
                    <td align="left" valign="top" class="sitemenu"><form id="form2" name="form1" method="post" action="action.php?action=editchar">
                      <table width="100%" border="0" cellspacing="1" cellpadding="0">
                        <tr>
                          <td colspan="7" align="left" valign="top" class="sitemenu">Selected Character: <?php echo $row_info['sID']; ?></td>
                        </tr>
                        <tr>
                          <td colspan="7" align="left" valign="top" bgcolor="#202020" class="sitemenu">Characterinfo:</td>
                        </tr>
                        <tr>
                          <td width="25%" align="right" valign="top" class="sitemenu">Charactername:</td>
                          <td width="25%" align="left" valign="top" class="sitemenu"><input name="charname" type="text" id="charname" size="30" value="<?php echo $row_info['sID']; ?>"/><input type='hidden' name='char_old' value='<?php echo $row_info['sID']; ?>' /></td>
                          <td width="25%" align="right" valign="top" class="sitemenu">Characterlevel:</td>
                          <td width="25%" align="left" valign="top" class="sitemenu"><select name="charlevel" id="charlevel">
<?php 
							for($count = 1; $count <= 150; $count++)
								{

									
									if ($count == $row_info['nLevel'])
										{
											echo "<option value='".$count."' selected='selected'>".$count."</option>";
										} else {
											echo "<option value='".$count."'>".$count."</option>";
										}
										
								}
?>
                          </select></td>
                        </tr>
                        <tr>
                          <td colspan="4" align="right" valign="top" class="sitemenu"><hr size="1" /></td>
                          </tr>
                        <tr>
                          <td colspan="2" align="center" valign="top" bgcolor="#202020">Characterstats:</td>
                          <td colspan="2" align="center" valign="top" bgcolor="#202020">More Info:</td>
                          </tr>
                        <tr>
                          <td align="right" valign="top" class="sitemenu">STR:</td>
                          <td align="left" valign="top" class="sitemenu"><input name="char_str" type="text" id="textfield5" value="<?php echo $row_info['nStrength']; ?>" size="3" maxlength="3" /></td>
                          <td align="right" valign="top" class="sitemenu">Adminlevel:</td>
                          <td align="left" valign="top" class="sitemenu"><?php echo $row_info['nAdminLevel']; ?></td>
                          </tr>
                        <tr>
                          <td align="right" valign="top" class="sitemenu">DEX:</td>
                          <td align="left" valign="top" class="sitemenu"><input name="char_dex" type="text" id="char_dex" value="<?php echo $row_info['nDexterity']; ?>" size="3" maxlength="3" /></td>
                          <td align="right" valign="top" class="sitemenu">Played Time:</td>
                          <td align="left" valign="top" class="sitemenu"><?php echo $row_info['nPlayMin']; ?>
                            min</td>
                          </tr>
                        <tr>
                          <td align="right" valign="top" class="sitemenu">END:</td>
                          <td align="left" valign="top" class="sitemenu"><input name="char_end" type="text" id="textfield6" value="<?php echo $row_info['nConstitute']; ?>" size="3" maxlength="3" /></td>
                          <td align="right" valign="top" class="sitemenu">Loginzone:</td>
                          <td align="left" valign="top" class="sitemenu"><?php echo $row_info['sLoginZone']; ?></td>
                          </tr>
                        <tr>
                          <td align="right" valign="top" class="sitemenu">INT:</td>
                          <td align="left" valign="top" class="sitemenu"><input name="char_int" type="text" id="textfield7" value="<?php echo $row_info['nIntelligence']; ?>" size="3" maxlength="3" /></td>
                          <td align="right" valign="top" class="sitemenu">HP:</td>
                          <td align="left" valign="top" class="sitemenu"><input name="char_hp" type="text" id="textfield10" value="<?php echo $row_info['nHP']; ?>" size="5" maxlength="5" /></td>
                          </tr>
                        <tr>
                          <td width="25%" align="right" valign="top" class="sitemenu">SPR:</td>
                          <td width="25%" align="left" valign="top" class="sitemenu"><input name="char_spr" type="text" id="char_spr" value="<?php echo $row_info['nMentalPower']; ?>" size="3" maxlength="3" /></td>
                          <td width="25%" align="right" valign="top" class="sitemenu">SP:</td>
                          <td width="25%" align="left" valign="top" class="sitemenu"><input name="char_sp" type="text" id="textfield11" value="<?php echo $row_info['nSP']; ?>" size="5" maxlength="5" /></td>
                          </tr>
						 <tr>
                          <td colspan="2" align="right" valign="top" class="sitemenu"><hr size="1" /></td>
                          <td colspan="2" align="right" valign="top" class="sitemenu"><hr size="1" /></td>
                         </tr>
						 <tr>
                          <td width="25%" align="right" valign="top" class="sitemenu">Experience:</td>
                          <td width="25%" align="left" valign="top" class="sitemenu"><input name="char_exp" type="text" id="char_spr" value="<?php echo $row_info['nExp']; ?>" size="20" maxlength="20" /></td>
                          <td width="25%" align="right" valign="top" class="sitemenu">Logincount:</td>
                          <td width="25%" align="left" valign="top" class="sitemenu"><?php echo $row_info['nLoginCount']; ?></td>
                         </tr>
                        <tr>
                          <td colspan="2" align="right" valign="top" class="sitemenu"><hr size="1" /></td>
                          <td colspan="2" align="right" valign="top" class="sitemenu"><hr size="1" /></td>
                          </tr>
                        <tr>
                          <td colspan="2" align="center" valign="top" bgcolor="#202020" class="sitemenu">Character Money:</td>
                          <td colspan="2" align="center" valign="top" bgcolor="#202020" class="sitemenu">Fame</td>
                          </tr>
                        <tr>
                          <td align="right" valign="top" class="sitemenu">Money: </td>
                          <td align="left" valign="top" class="sitemenu"><input name="char_money" type="text" id="textfield13" value="<?php echo $row_info['nMoney']; ?>" size="20" maxlength="20" /></td>
                          <td align="right" valign="top" class="sitemenu">Fame:</td>
                          <td align="left" valign="top" class="sitemenu"><input name="char_fame" type="text" id="textfield13" value="<?php echo $row_info['nFame']; ?>" size="20" maxlength="20" /></td>
                        </tr>
                        <tr>
                          <td colspan="4" align="right" valign="top" class="sitemenu"><hr size="1" /></td>
                          </tr>
                        <tr>
                          <td colspan="4" align="center" valign="top" class="sitemenu">
<?php
					if($_SESSION['level'] < 9)
						{
							echo "You can Only view Characterstats!!!";
						} else {
?>
						<input type="submit" name="editchardone" id="button2" value="Update Profile" />
<?php
						}
?>
							</td>
                          </tr>
                      </table>
                    </form></td>
                  </tr>
                </table>
<?php
						
				
				
					}
				if ($_SESSION['editcharstep'] == 3)
						{
?>
				<center><font color='yellow'><strong><?php echo $_SESSION['edit_msg']; ?></strong></font>
<?php
						}
						unset($_SESSION['editcharstep']);
						unset($_SESSION['edit_char']);
						unset($_SESSION['edit_msg']);
?>

              </td>
            </tr>
          </table>