<?php

include("../includes/site_config.php");
include('../session_handler.inc');

$area = 'member';

if(isset($_REQUEST['submit']))
	{
		$question=form_get('question');
		$char = form_get('char');
		$query=mysql_query("INSERT into essay_questions set essay_question='$question', characters='$char'");
	}

if(isset($_REQUEST['es_id']))
	{
		$es_id=form_get('es_id');
		mysql_query("DELETE from essay_questions where MD5(essay_id)='$es_id'") or die(mysql_error());
		mysql_query("DELETE from essay_answers where MD5(essays_id)='$es_id'") or die(mysql_error());
	}
?>
<?php include("include/header.php"); ?>
<style type="text/css">
<!--
.style1 {color: #FF0000;
	font-weight: bold;
}
-->
</style>

<div class="mainwidth">
<div class="admin-page-header"><div class="admin-page-heading">&nbsp;&nbsp;<?=ESSAY_ADMIN?></div></div>
<div class="clear"></div>
<div class="admin-page">
<table width="100%" align="<?php print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="<?php print("$CONST_TABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_TABLE_CELLPADDING"); ?>"><!--DWLayoutTable-->

  <tr>
    <td width="10" height="3">
      <?php
	  
        $query = "  SELECT *
                    FROM essay_questions
                 ";
$result=mysql_query($query, $link) or die(mysql_error());
$num = mysql_num_rows($result);
?>
<table width=100%>
    <!--<tr align=left>
      <td align=center colspan=3><?=$num?> <?php echo GENERAL_FOUND_USERS ?></td>
    </tr>-->
    <tr align=left>
      <th class="admin-head2" width="70%"><?php echo ESSAY_QUESTION ?></th><th class="admin-head2" width="15%"><?php echo MAX_CHAR_ESSAY ?></th><th class="admin-head2" align="center"><?=DELETE_ESSAY?></th>
	</tr>
	<tr> <td>&nbsp;</td></tr>
<?
while ($row = mysql_fetch_object($result)){?>
    <tr>
    <td width="50%"><li><?=$row->essay_question?></li></td>
	<td width=50%><?=$row->characters?></td>
	<td><? if($DEMO==false){?><a href="<?=$_SERVER['PHP_SELF']?>?es_id=<?=md5($row->essay_id)?>" onClick="javascript:return confirm('Are you sure you want to Selete this Essay?')">delete</a><? }?></td>
	</tr>
	<tr> <td>&nbsp;</td></tr>
<? } ?>
   
  </table>
  </td>
  </tr>
 <tr> <td>&nbsp;</td></tr>
 <tr> <td>&nbsp;</td></tr>
 <tr> <td>&nbsp;</td></tr>
 <tr> <td>&nbsp;</td></tr>
 <tr> <td>&nbsp;</td></tr>
  <tr><td>
  <table width="85%" border="0" cellspacing="0" cellpadding="0">
  <form name="essay" method="post" action="<?=$_SERVER['PHP_SELF']?>">
  <tr>
    <td class="admin-head2"><?=CREATE_ESSAY_QUESTION?> </td>
    <td>&nbsp;</td>
  </tr>
   <tr> <td>&nbsp;</td></tr>
   <tr>
    <td><input type="text" size="55" name="question" /></td>
    <td><div class=""><?=MAX_CHAR_ESSAY?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="char" size="10"/></div> </td>
  </tr>
  <tr> <td>&nbsp;</td></tr>
  <tr>
    <td>&nbsp;</td>
    <td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="submit" value="Add Question" /></td>
  </tr>
  </form>
</table>
  </td></tr>

<tr>
    <td height="57" colspan="2" valign="top"><p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p><span class="style1">Note:</span><b> Create the essay questions in order of how you want them to appear on the Edit Essay section of the My Media area of the user side.</b></p></td>
    <td width="4">&nbsp;</td>
  </tr>
  <tr>  
</table>
</div><div class="admin-page-bottom"></div></div>
<?php include("include/footer.php"); ?>