i am working on an administration section where i would like to have a link where i click to
update each row of products. i would like to click the update link where it takes me to a page
where i can update the product item, item name, image, description, and price.
at the moment, i have a page where i show all of the products that i have on each page of my
website. i also a delete link where i can delete each row, the only things that i need help with
is a confirm to delete page, so that i can confirm the deleted row before i delete a row and also
the update link where it takes me to that page where i can update that row.
does anyone know how to do that and/or can someone help me out with that?
much help would be appreciated.
thanks
the code that i have to show everything in each of the products pages is:
PHP Code:
<?
require_once('book_sc_fns.php');
session_start();
do_html_header('Administration');
$dbname = "rmgiusa";
$tblname = "items";
$linkid = mysql_connect("localhost", "username", "pass") or die("Couldn't connect.");
$db = mysql_select_db($dbname, $linkid) or die("Couldn't select database.");
mysql_query ("SELECT * FROM $tblname");
echo "$select<br>";
$host ="localhost";
$dbuser="username";
$dbpass="pass";
$database="rmgiusa";
mysql_connect($host,$dbuser,$dbpass);
mysql_select_db($database) or die ("Unable to select database");
$query="SELECT * FROM $tblname ORDER BY itemId ASC";
$result=mysql_query($query);
$num=mysql_num_rows($result);
$result = mysql_query($query, $linkid);
include("include_code5.php");
$result = mysql_query($query);
include("db2.php");
switch($_GET["action"])
{
case "delete_item_row":
{
DeleteItemRow($_GET["id"]);
break;
}
case "delete_proditem_row":
{
DeleteProdItemRow($_GET["id"]);
break;
}
case "delete_order_row":
{
DeleteOrderRow($_GET["id"]);
break;
}
case "show_item_row":
{
ShowItemRow($_GET["id"]);
break;
}
case "update_item_row":
UpdateItemRow($_GET["id"]);
default:
}
function DeleteItemRow($itemId)
{
global $dbServer, $dbUser, $dbPass, $dbName;
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("DELETE FROM user WHERE itemId=$itemId");
}
function DeleteProdItemRow($itemId)
{
global $dbServer, $dbUser, $dbPass, $dbName;
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("DELETE FROM items WHERE itemId=$itemId");
}
function DeleteOrderRow($id)
{
global $dbServer, $dbUser, $dbPass, $dbName;
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("DELETE FROM checkout WHERE id=$id");
}
function ShowItemRow($itemId)
{
global $dbServer, $dbUser, $dbPass, $dbName;
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("SELECT * FROM items WHERE itemId='$itemId'");
}
hello mike,
i'm +1 in simplicity, so i think that putting a javascript confirm on the delete link is more convenient than confirming it at the deletion page. (although sometimes this doesn't work when the browser disables js -> you can create an is_js_enabled script that will prevent users from disabling js)
Code:
<script language="javascript">
<!--
function confirmDeleteID(id) {
var message;
var ok;
message = 'Are you sure to delete this item with id : ' + id + '?';
ok = confirm(message);
if(!ok) {
return false;
}
return true;
}
//-->
</script>