Current location: Hot Scripts Forums » Programming Languages » PHP » need help creating an update section


need help creating an update section

Reply
  #1 (permalink)  
Old 11-30-04, 01:32 PM
mikewooten mikewooten is offline
Newbie Coder
 
Join Date: Feb 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
need help creating an update section

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-30-04, 03:25 PM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
If you have the code to list the products then do that in the updateproducts.php and set the retrieved values as variables!

So if you have 'link.php?id=1' then to edit it go to 'edit.php?id=1' and use:

PHP Code:

<?php


//connect to db

$query "SELECT item, name, description FROM table WHERE id='$_GET[id]'";
$result mysql_query($query) or die(mysql_error());
while(
$rmysql_fetch_array($result)) {
$item $r['item'];
$name $r['name'];
$description $r['description'];
}

?>
Then have a form:

PHP Code:

Item: <input type="text" name="item" value="<? echo $item?>">


//etc..
And just add the values in the db (will overwrite the old ones)!
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 11-30-04, 11:40 PM
mikewooten mikewooten is offline
Newbie Coder
 
Join Date: Feb 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
thats similar to what i have and for some reason the update link will NOT work on the showprod4.php page, when you rollover the link, the ID does not show up, how can i get the ID to show up and go to the edit.php page?
here is my code that i have for the showprod4.php page

PHP Code:

<?

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.");


$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="edit1.php?id='.$row['prodItems'].'">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 edit1.php page

PHP Code:

$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."); 
$txtCatID=(isset($_GET['catid']) ? intval($_GET['catid']) : "");

if (
$record_id) {
$query="SELECT * FROM $tblname WHERE catid=$txtCatID"
$num=mysql_num_rows($result);  
$result mysql_query($query$linkid); 
echo(
'<form action="edit.php" method="post">');
echo(
'<input type="hidden" name="catid" value="'.$txtCatID.'">');
echo(
'<input type="hidden" name="prodItems" value="'.$txtprodItems.'">');
echo(
'Item Name: <input type="text" name="itemName" value="'.$row['itemName'].'"><br />');
echo(
'Item Description: <input type="text" name="itemDesc" value="'.$row['itemDesc'].'"><br />');
echo(
'Item Price: <input type="text" name="itemPrice" value="'.$row['itemPrice'].'"><br />');
echo(
'Item Image: <input type="text" name="ItemImage" value="'.$row['ItemImage'].'"><br />');
echo(
'<input type="submit" name="submit" value="submit">');
echo(
'</form>');

i really don't know what is wrong with these coding, but also when i go to the edit1.php page, it shows up blank.
can you help me to get this to work?
thanks
here is the page that i am trying to work with
http://www.wootenmedia.com/rmg/test/showprod4.php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 12-02-04, 11:04 AM
mikewooten mikewooten is offline
Newbie Coder
 
Join Date: Feb 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
need help adding addslashes() and stripslashes()

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:
PHP Code:



<?
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();
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 12-02-04, 02:33 PM
mikewooten mikewooten is offline
Newbie Coder
 
Join Date: Feb 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
need help creating a confirmation to delete page

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:

PHP Code:

<?

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();
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The Art Nexus seeking PHP programmers TheArtNexus Job Offers & Assistance 5 02-26-08 04:08 AM
need help creating an update & confirm page mikewooten PHP 1 11-08-04 05:28 PM
need help creating an update page within admin mikewooten PHP 2 11-01-04 11:39 PM
Help with multipart update form into MySQL DB... jimb575 PHP 0 07-01-04 03:42 PM
Compare and update perleo PHP 2 10-27-03 04:53 AM


All times are GMT -5. The time now is 07:37 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.