Location: PHPKode > projects > Guild DKP System > dkpsystem1.4/includes/admin/itemconfiguration.php
<?php
$Update = $_POST[Update];
$Create = $_POST[Create];
$Remove = $_POST[Remove];
$Save = $_POST[Save];
$option = $_GET[option];
if(isset($Save)) {
	$itemid = $_POST[itemid];
	$txtName = $_POST[txtName];
	$selectSlot = $_POST[selectSlot];
	$txtValue = $_POST[txtValue];
	$selectType = $_POST[selectType];
	$txtNote = $_POST[txtNote];
	$sql = $db->query("UPDATE dkp_items SET name=\"$txtName\", type=\"$selectType\", value=\"$txtValue\", slot=\"$selectSlot\", note=\"$txtNote\" WHERE name=\"$txtName\"");
	if($sql) { die(systemMessage("Item Updated", "You have successfully updated this item.")); }
	else { die(systemMessage("Database Error", mysql_error())); }
}
elseif(isset($Create)) {
	$txtName = $_POST[txtName];
	$selectSlot = $_POST[selectSlot];
	$txtValue = $_POST[txtValue];
	$selectType = $_POST[selectType];
	$txtNote = $_POST[txtNote];
	$sql = $db->query("INSERT INTO dkp_items (name, type, value, slot, note) VALUES (\"$txtName\", \"$selectType\", \"$txtValue\", \"$selectSlot\", \"$txtNote\")");
	if($sql) { die(systemMessage("Item Created", "You have successfully created a new item.")); }
	else { die(systemMessage("Database Error", mysql_error())); }
	
}
elseif(isset($Remove)) {
	$itemid = $_POST[selectItem];
	$sql = $db->query("DELETE FROM dkp_items WHERE id=\"$itemid\"");
	if($sql) { die(systemMessage("Item Deleted", "You have successfully deleted an item.")); }
	else { die(systemMessage("Database Error", mysql_error())); }
}
?>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
  <tr>
    <td bgcolor="#003366"><font color="#FFFFFF" size="2" face="Tahoma"><strong>Item 
      Configuration</strong></font></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td><form action="" method="post" name="formSelectItem" id="formSelectItem">
        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr bgcolor="#003366"> 
            <td colspan="2"><strong><font color="#CCCCCC" size="1" face="Tahoma">Items</font></strong></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#999999"><strong><font size="1" face="Tahoma"><u>Name</u></font></strong></td>
            <td bgcolor="#CCCCCC"><strong><font size="1" face="Tahoma"> 
              <select name="selectItem" id="selectItem">
			  <option>Please select an item to update</option>
				<option>--</option>
				<?php
				$sql = $db->query("SELECT id, name FROM dkp_items ORDER BY name ASC");
				if($db->count_rows($sql) > 0) {
					while($row = mysql_fetch_array($sql)) {
						$name = $row[name];
						$id = $row[id];
						echo "<option value=\"$id\">$name</option>";
					}
				}
				else {
					echo "<option>There are no items in the database.</option>";
				}
				?>
              </select>
              <input name="Update" type="submit" id="Update" value="Update">
              <input name="Remove" type="submit" id="Remove" value="Remove">
              </font></strong></td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
  <tr> 
    <td bgcolor="#003366"><font color="#CCCCCC" size="1" face="Tahoma"><strong>Options</strong></font></td>
  </tr>
  <tr>
    <td bgcolor="#999999"><font size="1" face="Tahoma"><strong><a href="?d=admin&s=itemconfiguration&option=create"><font color="#000000">Create 
      Item </font></a></strong></font></td>
  </tr>
</table>

<?php
if(isset($Update)) {
	$itemid = $_POST[selectItem];
	$sql = $db->query("SELECT * FROM dkp_items WHERE id=\"$itemid\"");
	while($row = mysql_fetch_array($sql)) {
		$itemid = $row[id];
		$name = $row[name];
		$slot = $row[slot];
		$slotname = @mysql_result($db->query("SELECT name FROM dkp_itemtypes WHERE id=\"$slot\""), 0);
		$value = $row[value];
		$type = $row[type];
		$note = $row[note];
		if($type == 1) { $typename = "Class Item"; }
		elseif($type == 0) { $typename = "General Item"; }
	}
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><form action="" method="post" name="formUpdateItems" id="formUpdateItems">
        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr> 
            <td colspan="2" bgcolor="#003366"><font color="#CCCCCC" size="1" face="Tahoma"><strong>Details</strong></font></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Name</font></strong></u></td>
            <td bgcolor="#CCCCCC">
<input name="txtName" type="text" id="txtName" value="<?php echo $name; ?>" size="35"></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Slot</font></strong></u></td>
            <td bgcolor="#CCCCCC"> 
              <select name="selectSlot" size="1" id="selectSlot">
                <option value="<?php echo $slot; ?>"><?php echo $slotname; ?></option>
                <option>--</option>
				<?php
				$sql2 = $db->query("SELECT * FROM dkp_itemtypes ORDER BY name ASC");
				while($row2 = mysql_fetch_array($sql2)) {
					echo "<option value=\"$row2[id]\">$row2[name]</option>";
				}
				?>
              </select></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Point 
              Value</font></strong></u></td>
            <td bgcolor="#CCCCCC">
<input name="txtValue" type="text" id="txtValue" value="<?php echo $value; ?>" size="10"></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Type</font></strong></u></td>
            <td bgcolor="#CCCCCC"> <select name="selectType" id="selectType">
                <option value="<?php echo $type; ?>"><?php echo $typename; ?></option>
                <option>--</option>
                <option value="0">General Item</option>
                <option value="1">Class Item</option>
              </select></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Note</font></strong></u></td>
            <td bgcolor="#CCCCCC">
<input name="txtNote" type="text" id="txtNote" value="<?php echo $note; ?>" size="35"></td>
          </tr>
          <tr>
            <td bgcolor="#999999">&nbsp;</td>
            <td bgcolor="#CCCCCC">
<input name="Save" type="submit" id="Save" value="Save">
              <input name="itemid" type="hidden" id="itemid" value="<?php echo $itemid; ?>"> </td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<?php
}
if($option == "create" && !isset($Update)) {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="00">
  <tr>
    <td><form action="" method="post" name="formCreateItem">
        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr> 
            <td colspan="2" bgcolor="#003366"><font color="#CCCCCC" size="1" face="Tahoma"><strong>Details</strong></font></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Name</font></strong></u></td>
            <td bgcolor="#CCCCCC"> <input name="txtName" type="text" size="35"></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Slot</font></strong></u></td>
            <td bgcolor="#CCCCCC"> <select name="selectSlot" size="1">
                <option value="0">Slot</option>
                <option value="0">--</option>
                <?php
				$sql2 = $db->query("SELECT * FROM dkp_itemtypes ORDER BY name ASC");
				while($row2 = mysql_fetch_array($sql2)) {
					echo "<option value=\"$row2[id]\">$row2[name]</option>";
				}
				?>
              </select></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Point 
              Value</font></strong></u></td>
            <td bgcolor="#CCCCCC"> <input name="txtValue" type="text"size="10"></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Type</font></strong></u></td>
            <td bgcolor="#CCCCCC"> <select name="selectType">
                <option value="0">Type</option>
                <option value="0">--</option>
                <option value="0">General Item</option>
                <option value="1">Class Item</option>
              </select></td>
          </tr>
          <tr> 
            <td bgcolor="#999999"><u><strong><font color="#000000" size="1" face="Tahoma">Note</font></strong></u></td>
            <td bgcolor="#CCCCCC"> <input name="txtNote" type="text" size="35"></td>
          </tr>
          <tr> 
            <td bgcolor="#999999">&nbsp;</td>
            <td bgcolor="#CCCCCC"> <input name="Create" type="submit" id="Create" value="Create"></td>
          </tr>
        </table>
      </form></td>
  </tr>
</table>
<?php
}
?>
Return current item: Guild DKP System