SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Apr 2004
    Location
    duluth
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  2. #2
    SitePoint Evangelist elgumbo's Avatar
    Join Date
    Nov 2002
    Location
    North West, UK
    Posts
    545
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Have you read Kevin Yanks book? It covers all this - http://www.sitepoint.com/books/phpmysql1/

  3. #3
    SitePoint Member
    Join Date
    Apr 2004
    Location
    duluth
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need help adding addslashes() and stripslashes()

    thanks for the suggestion, i'll look into that book
    i have a question that i'm trying to work on.
    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();
    ?>

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    use strip slashes when you are echoing the result and add slashes when you are inserting the data into the table.

    One point, instead of echoing vast rows of table, break out of php and echo as normal then jump back in to php......
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Member
    Join Date
    Apr 2004
    Location
    duluth
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how would the stripslashes look?
    would it be something like this?
    echo "<td>stripslashes($query_data[0])</td>";

    why break out of php then jump back in to php, is it better to do it that way than to just use php? just wondering.
    thanks

  6. #6
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's more efficient to jump out of php, then to echo out the HTML.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  7. #7
    SitePoint Member
    Join Date
    Apr 2004
    Location
    duluth
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •