Location: PHPKode > projects > SiteX > admin/polls_edit.php
<?PHP
ob_start();
session_start();
include("../includes/globals.php.inc");
include("../includes/functions.php");
include("../lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("../lang/".$sxSetup['Language'].".php");
include("../themes/$THEME_FOLDER/config.php.inc");
if((!userEditor())AND(!userAdmin()))  loginError($sxLang['LoginRequired']);
if((userEditor())AND(!$sxSetup['EditorRightsPollsEdit']))  loginError($sxLang['LoginRequired']);

if($delete)
{
	$query = "SELECT * FROM $DB_Polls_Values WHERE id='$delete'";
	$result = mysql_query($query, $Link) or queryError("31", mysql_error());
	$ROW = mysql_fetch_object($result);
	$editid = $ROW->pollid;
	
	$query = "DELETE FROM $DB_Polls_Values WHERE id='$delete'";
	$result = mysql_query($query, $Link) or queryError("31", mysql_error());
	$message = $sxLang['MessagePollItemDeleted'];
}

if($Edit)
{	
	$query = "UPDATE $DB_Polls SET name='$name' WHERE id='$editid'";
	$result = mysql_query($query, $Link) or queryError("31", mysql_error());
	$message = $sxLang['MessagePollNameUpdated'];
}

if($Add)
{	
	$query = "INSERT INTO $DB_Polls_Values (value, pollid, votes) VALUES ('$new_value', '$editid', '0')";
	$result = mysql_query($query, $Link) or queryError("31", mysql_error());
	$message = $sxLang['MessagePollItemAdded'];
}

$query = "SELECT * FROM $DB_Polls WHERE id='$editid'";
$result = mysql_query($query, $Link) or queryError("31", mysql_error());
$ROW = mysql_fetch_object($result);
	
$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function confirmDelete(theID,theName){
	if(confirm("<?PHP echo $sxLang['GeneralJSDeleteEntry3']; ?> '"+theName+"' <?PHP echo $sxLang['GeneralJSDeleteEntry2']; ?>")){
		window.location='<?PHP print $PHP_SELF."?delete="; ?>'+theID;
	}
}
//-->
</script>     
<div class="bodyWrapper">
  <h1 class="sxAdminHeading"><?PHP echo $sxLang['PollsHeadingEdit']; ?></h1>
   <div class="sxAdminBreadcrumbs"><?PHP if(userAdmin()) { ?><a href="index.php"><?PHP echo $sxLang['AdminBreadcrumb']; ?><?PHP }?><?PHP if(userEditor()) { ?><a href="editor_index.php"><?PHP echo $sxLang['EditorBreadcrumb']; ?><?PHP }?></a> > <a href="polls.php"><?PHP echo $sxLang['PollsHeadingManager']; ?></a> > <?PHP echo $sxLang['PollsHeadingEdit']; ?></div>  
   <?PHP echoMessage($message); ?>
	<p><form name="sxFormPollEdit" method="post" action="<?PHP echo $PHP_SELF; ?>">
	  <input name="name" type="text" id="name" size="35" maxlength="255" value="<?PHP echo $ROW->name; ?>" />
	  <input name="editid" type="hidden" id="editid" value="<?PHP echo $editid; ?>" />
	  <input name="Edit" type="submit" id="Edit Name" value="<?PHP echo $sxLang['ButtonEditName']; ?>" class="sxButton" />
	</form></p>
	<table border="0" cellspacing="2" cellpadding="5">
	  <tr>
		<td class="tableColumn"><?PHP echo $sxLang['GeneralItemValue']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['PollsItemVotes']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['GeneralItemOptions']; ?></td>
	  </tr><?PHP
		$query2 = "SELECT * FROM $DB_Polls_Values WHERE pollid='$editid' ORDER BY id ASC";
		$result2 = mysql_query($query2, $Link) or queryError("27", mysql_error());
		while($ROW2 = mysql_fetch_object($result2)){
			echo '  <tr bgcolor="' . $sxTheme['ColorTableRow'] . '">';
			echo '     <td>' .  htmlspecialchars($ROW2->value) . '</td>';
			echo '     <td align="center">' . $ROW2->votes . '</td>';
			echo '     <td>';
			echo '       <a href="#" onclick="confirmDelete(' . $ROW2->id . ',\'' .  htmlspecialchars(addslashes($ROW2->value)) . '\')"><img src="../images/admin_delete.gif" style="border: 0;" alt="' . $sxLang['ButtonDelete'] . '" /></a></td>';
			echo '  </tr>';
		}
		?></table>
	<form name="sxFormPollAddItem" method="post" action="<?PHP echo $PHP_SELF; ?>">
	  <input name="new_value" type="text" id="new_value" size="35" maxlength="255" />
	  <input name="editid" type="hidden" id="editid" value="<?PHP echo $editid; ?>" />
	  <input name="Add" type="submit" id="Add" value="<?PHP echo $sxLang['PollsButtonAddItem']; ?>" class="sxButton" />
	</form>
	<p>&nbsp;</p>
  </div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX