<?php
include "../includes/header.php";
$action = $_GET['action'];
$rowid = $_GET['id'];
switch($action)
{
/* MORE DETAILED VIEW */
case "view":
include "../includes/db_login.php";
$query = "SELECT * FROM tblname WHERE rowid = '$rowid'";
$result = mysql_query( $query );
if(!$result)
{
die("Could not query the database: <br/>" . mysql_error());
}
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$rowid = $row['rowid'];
$company = $row['company'];
$product = $row['product'];
$description = $row['description'];
$web = $row['web'];
$last = $row['last'];
$used = $row['used'];
$active = $row['active'];
echo '
<p class="casetext">Below is a more detailed description of <b>' . $product . '</b>.</p>
<table border="0" align="center" cellpadding="4" style="margin-bottom: 5px;">
<tr>
<td>Company:</td>
<td>' . $company . '</td>
</tr>
<tr>
<td>Product:</td>
<td>' . $product . '</td>
</tr>
<tr>
<td>Description:</td>
<td>' . $description . '</td>
</tr>
<tr>
<td>Web Address:</td>
<td><a href="' . $web . '" target= "_blank">' . $web . '</a></td>
</tr>
<tr>
<td>Last Used:</td>
<td>' . $last . '</td>
</tr>
<tr>
<td>When was <b>' . $product . '</b> last used:</td>
<td>' . $used . '</td>
</tr>
<tr>
<td>Is <b>' . $product . '</b> Active or Inactive?:</td>
<td>' . $active . '</td>
</tr>
</table>
<p class="casetext" style="font-size: 125%;"><a href="hrdb.php">Go back to database?</a></p>
';
}
mysql_close($connection);
include_once "../includes/footer.php";
exit;
break;
/* END DETAILED VIEW */
/* EDIT MODE */
case "edit":
include "../includes/db_login.php";
$query = "SELECT * FROM tblname WHERE rowid = '$rowid'";
$result = mysql_query( $query );
if(!$result)
{
die("Could not query the database: <br/>" . mysql_error());
}
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$id = $row['rowid'];
$company = $row['company'];
$product = $row['product'];
$description = $row['description'];
$web = $row['web'];
$last = $row['last'];
$used = $row['used'];
$active = $row['active'];
echo '
<p class="casetext">Below is a more detailed description of <b>' . $product . '</b>.</p>
<form action="hrdbcase.php?action=doedit" method="post" name="form1">
<p><input type="hidden" name="rowid" value="' . $id . '" /></p>
<table border="0" align="center" cellpadding="4" style="margin-bottom: 5px;">
<tr>
<td>Company:</td>
<td><input type="text" name="company" value="' . $company . '" /></td>
</tr>
<tr>
<td>Product:</td>
<td><input type="text" name="product" value="' . $product . '" /></td>
</tr>
<tr>
<td>Description:</td>
<td><input type="text" name="description" value="' . $description . '" /></td>
</tr>
<tr>
<td>Web Address:</td>
<td><input type="text" name="web" value="' . $web . '" /></td>
</tr>
<tr>
<td>Last Used:</td>
<td><input type="text" name="last" value="' . $last . '" /></td>
</tr>
<tr>
<td>When was <b>' . $product . '</b> last used:</td>
<td><input type="text" name="used" value="' . $used . '" /></td>
</tr>
<tr>
<td>Is <b>' . $product . '</b> Active or Inactive?:</td>
<td><input type="text" name="active" value="' . $active . '" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
<p class="casetext" style="font-size: 125%;"><a href="hrdb.php">Go back to database?</a></p>
';
}
mysql_close($connection);
include "../includes/footer.php";
exit;
break;
/* END EDIT MODE*/
/* EDIT ACTION HELD HERE */
case "doedit":
include "../includes/db_login.php";
$query="
UPDATE tblname
SET
company = '" . $company . "',
product = '" . $product . "',
description = '" . $description . "',
web = '" . $web . "',
last = '" . $last . "',
used = '" . $used . "',
active = '" . $active . "'
WHERE
rowid = '" . $rowid . "'
";
$result = mysql_query($query);
if(!$result)
{
die("Could not query the database: <br/>" . mysql_error());
} else {
echo '<p class="casetext">Item Updated</p>';
}
mysql_close($connection);
include "../includes/footer.php";
exit;
break;
/* END EDIT ACTION */
case "delete":
$id = $_GET['id'];
echo '<p class="casetext">Are you sure you want to <strong>delete</strong> this item?<br/>';
echo 'This is a final action. If you make a mistake, this cannot be undone.<br/>';
echo '<a href="hrdbcase.php?action=dodelete&id=' . $id . '"><big>Yes, Delete This</big></a> | <a href="hrdb.php"><big>No, Go Back</big></a> ';
echo '</p>';
include_once "../includes/footer.php";
exit;
break;
case "dodelete":
include "../includes/db_login.php";
$query="DELETE FROM hrlanding WHERE rowid='" . $id . "'";
$result = mysql_query($query);
if(!$result)
{
die("Could not query the database: <br/>" . mysql_error());
} else {
echo '<p class="casetext">Item has been permanetly deleted<br/>';
echo 'To return to the database, <a href="hrdb.php">Click Here</a></p>';
}
include_once "../includes/footer.php";
exit;
break;
}
include "../includes/footer.php";
?>
The following code above is being used to edit/updated/delete an item in a database. Well I can view the information perfectly, but when I try to edit the information, I get a successful message but the edits do not go through. And when you try to delete an item the delete command does not delete the item. I need help URGENTLY! Thanks for any suggestions in advance.
-Dennis