Page 1 of 1

need help creating an update section

Posted: Tue Nov 30, 2004 12:25 pm
by mikewooten
i am working on an administration section. i need help creating an edit/update page where i click the update link on a showproducts.php page, and that link goes to an updateproducts.php page where i can fill out a form on that updateproducts.php page then when i click on the submit button, it updates that product. The information that i would like to update is the category ID, Item ID, Product Item, Item Name, Item Image, Item Description and Item Price.
so far all that i have is just the form, i need help creating the php code for this to work.

is there anyone that can help me out with this, much help would be appreciated.
thanks

Posted: Tue Nov 30, 2004 12:32 pm
by kettle_drum
Process the data submitted in the form and then update the database:

Code: Select all

UPDATE table SET field = '$_POSTїfield]' WHERE id = '$id';

Posted: Tue Nov 30, 2004 12:53 pm
by mikewooten
what PHP code would i have to use to process the data submitted within the form?
thanks

need help with getting information inside of a form

Posted: Wed Dec 01, 2004 2:24 pm
by mikewooten
i'm still trying to get this edit page to work, where i could edit each of the product rows. i have two php pages, i am getting an ID number on the showprod4.php page when i rollover the link, but when i go to the edit2.php page a form does show up, but there is no information that is going inside of the form from the showprod4.php page. how do you get information inside of that form from the showprod4.php page?

here is my code for the showprod4.php page:

Code: Select all

<?
require_once('book_sc_fns.php'); 
session_start();
do_html_header('Administration');
$dbname = "mwooten1_rmgiusa"; 
$tblname = "items"; 
$linkid = mysql_connect("localhost", "username", "password") 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="password";
	$database="mwooten1_rmgiusa";				
mysql_connect($host,$dbuser,$dbpass);
mysql_select_db($database) or die ("Unable to select database");    
$query="SELECT * FROM $tblname ORDER BY itemId ASC";  
$num=mysql_num_rows($result);  
$result = mysql_query($query, $linkid);   
include("include_code5.php");  

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>";
?>
deleterow
<?
echo "</td>";
echo "<td>";
echo('<table border="1"><tr><td><a href="edit2.php?id='.$query_data[1].'">edit'.$row['catid'].'</a></td><td>'.$row['itemName'].'</td><td>'.$row['itemDesc'].'</td><td>'.$row['temPrice'].'</td><td>'.$row['ItemImage'].'</td></tr></table>');
echo "</td>";
echo "</tr>";
}     
echo "</table>"; 
do_html_footer();
?>

and here is the code that i have for the edit2.php page

Code: Select all

<?
error_reporting(E_ALL ^ E_NOTICE);
    $tblname = "items";
    $host="localhost";
    $dbuser="username";
    $dbpass="password";
    $database="mwooten1_rmgiusa";                 
mysql_connect($host,$dbuser,$dbpass);
mysql_select_db($database) or die ("Unable to select database");
$txtCatID=(isset($_GET['id']) ? intval($_GET['id']) : "");
if ($txtCatID) {
$query="SELECT * FROM $tblname WHERE itemId='".$txtCatID."'"; 
$result=mysql_query($query);   
$row=mysql_fetch_array($result);
foreach ($row as $index => $value)
    echo "$index - $value<br />"; 
?>
<form action="edit.php" method="post">
Category ID: <input type="text" name="catid" value="<? echo $row['txtCatID']; ?>"><br />
Product Item: <input type="text" name="prodItems" value="<? echo $row['txtprodItems']; ?>"><br />
Item Name: <input type="text" name="itemName" value="<? echo $row['txtItemName']; ?>"> <br />
Item Description: <input type="text" name="itemDesc" value="<? echo $row['txtitemDesc']; ?>"><br />
Item Price: <input type="text" name="itemPrice" value="<? echo $row['txtitemPrice']; ?>"><br />
Item Image: <input type="text" name="ItemImage" value="<? echo $row['txtItemImage']; ?>"><br />
<input type="submit" name="submit" value="submit"><input type="reset" />
</form>
<?

}

?>

need help adding addslashes() and stripslashes()

Posted: Thu Dec 02, 2004 10:01 am
by mikewooten
i have this code on the showprod4.php page, where could i add addslashes() and stripslashes()?
could someone help me out with this?
thanks
here's the code:

Code: Select all

<?
require_once('book_sc_fns.php');
session_start();
do_html_header('Administration');

$dbname = "mwooten1_rmgiusa"; 
$tblname = "items"; 
$linkid = mysql_connect("localhost", "username", "password") 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="password";
	$database="mwooten1_rmgiusa";				
mysql_connect($host,$dbuser,$dbpass);
mysql_select_db($database) or die ("Unable to select database");    
$query="SELECT * FROM $tblname ORDER BY itemId ASC";  
$num=mysql_num_rows($result);  
$result = mysql_query($query, $linkid);   
include("include_code5.php");  
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>";
?>
deleterow
<?
echo "</td>";
echo "<td>";
echo('<table border="1"><tr><td><a href="edit2.php?id='.$query_data[1].'">edit'.$row['catid'].'</a></td><td>'.$row['itemName'].'</td><td>'.$row['itemDesc'].'</td><td>'.$row['temPrice'].'</td><td>'.$row['ItemImage'].'</td></tr></table>');
echo "</td>";
echo "</tr>";
}     
echo "</table>";  
do_html_footer();
?>

need help creating a confirmation to delete page

Posted: Thu Dec 02, 2004 1:32 pm
by mikewooten
i need a confirm link on the showprod4.php page that when clicked takes me to another page (a confirmation page) where that page shows me that one row of information from the showprod4.php page on that confirmation page. then on the confirmation page i have the option to delete that one row or go back to the show products page.
can anyone help me out with this
any help would be much appreciated
thanks

the code that i have for showprod4.php page is:

Code: Select all

<?
require_once('book_sc_fns.php'); 
session_start();
do_html_header('Administration');

$dbname = "mwooten1_rmgiusa"; 
$tblname = "items"; 
$linkid = mysql_connect("localhost", "username", "password") 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="password";
	$database="mwooten1_rmgiusa";				
mysql_connect($host,$dbuser,$dbpass);
mysql_select_db($database) or die ("Unable to select database");    
$query="SELECT * FROM $tblname ORDER BY itemId ASC";  
$num=mysql_num_rows($result);  
$result = mysql_query($query, $linkid);   
include("include_code5.php"); 

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>".stripslashes($query_data[0])."</td>";
echo "<td>".stripslashes($query_data[1])."</td>";
echo "<td>".stripslashes($query_data[2])."</td>"; 
echo "<td>".stripslashes($query_data[3])."</td>";
echo "<td><img src='../p_imgs/$query_data[4]'></td>";
echo "<td>".stripslashes($query_data[5])."</td>";
echo "<td>".stripslashes($query_data[6])."</td>";
echo "<td>";
?>
deleterow
<?
echo "</td>";
echo "<td>";
echo('<table border="1"><tr><td><a href="edit2.php?id='.$query_data[1].'">edit'.$row['catid'].'</a></td><td>'.$row['itemName'].'</td><td>'.$row['itemDesc'].'</td><td>'.$row['temPrice'].'</td><td>'.$row['ItemImage'].'</td></tr></table>');
echo "</td>";
echo "</tr>";
}     
echo "</table>";  
do_html_footer();
?>