Page 1 of 1

need help creating an update page within admin

Posted: Mon Nov 01, 2004 12:00 pm
by mikewooten
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:

Code: Select all

<?
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);

echo "<table border='1' bordercolor='#000000' cellpadding='0' cellspacing='0' width='100%'>";  
echo "<tr>";
echo "<td width='5%'><strong><center>cat id</center></strong></td>";
echo "<td width='6%'><strong><center>item id</center></strong></td>";
echo "<td width='10%'><strong><center>product item</center></strong></td>"; 
echo "<td width='10%'><strong><center>item name</center></strong></td>"; 
echo "<td width='20%'><strong><center>item image</center></strong></td>";
echo "<td width='30%'><strong><center>item desc</center></strong></td>";
echo "<td width='14%'><strong><center>item price</center></strong></td>";
echo "<td width='5%'><strong><center>Delete</td>";
echo "<td width='5%'><strong><center>Update</td>";
echo "</tr>";
while($query_data = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td>$query_data[0]</td>";
echo "<td>$query_data[1]</td>";
echo "<td>$query_data[2]</td>"; 
echo "<td>$query_data[3]</td>";
echo "<td><img src='../p_imgs/$query_data[4]'></td>";
echo "<td>$query_data[5]</td>";
echo "<td>$query_data[6]</td>";
echo "<td>";
?>
<br>
<a href="showprod4.php?action=delete_proditem_row&id=<?php echo $query_data[1];  ?>">delete</a>
<br>
<a href="prod_confirm.php">confirm</a>
<?
echo "</td>";
echo "<td>";
?>
<a href="prod_update.php">update</a>
<?
echo "</td>";
echo "</tr>";
}     
echo "</table>";  

do_html_footer();

?>
________________________________________________________________________________________


include_code5.php
is this:




Code: Select all

<?php

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'");
	}
	
	 function UpdateItemRow($itemId)
	{
	    	$txtCatID = $_POST['txtCatID'];
            $txtprodItems = $_POST['txtprodItems'];
            $txtItemName = $_POST['txtItemName'];
            $txtItemDesc = $_POST['txtItemDesc'];
            $txtItemPrice = $_POST['txtItemPrice'];           
	    	$txtItemImage = $_FILES['txtItemImage']['name'];
			
	  		$theSQL = "update items set proditems='txtprodItems', catid='$txtCatID', itemName='$txtItemName', itemDesc='$txtItemDesc', itemPrice='$txtItemPrice', itemPrice='$txtItemPrice', ItemImage='$txtItemImage')";
$theSQL = $theSQL + " where itemID = '$txtItemID'";   
	}

?>

?

Posted: Tue Nov 02, 2004 1:42 pm
by mikewooten
can anyone help with the update?
any help would be much appreciated
thanks