Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php code to update tables in phpmyadmin

    Hi,
    I was wondering could anybody help me. I am using php myadmin and want to move data from one table to another within the same database. I want this to happen when a user clicks a button which is within the php code.

    So far I have created the button and when it is clicked it updates the database but with all products, does anybody know how I can get it to update for one particular product and then remove it from the table once chosen and move it to another table?

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Sounds like a pretty easy issue. Whats your MySQL experience? Do you have code for us to see?

  • #3
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I dont have much experience at all, but Im creating a website at uni.

    PHP Code:
    <?php
                
                
    if($num>0){ //check if more than 0 record found

                    
    echo "<table border='1'>";//start table
        
                //creating our table heading
                    
    echo "<tr>";
                    echo 
    "<th>Product</th>";
                    echo 
    "<th>Add</th>";
                
                    echo 
    "</tr>";
            
                
    //retrieve our table contents
                    
    while($row=mysql_fetch_array($rs)){
                
    //extract row
                //this will make $row['firstname'] to
                //just $firstname only
                    
    extract($row);
                
                
    //creating new table row per record
                    
    echo "<tr>";
                    echo 
    "<td>{$productname}</td>";
                    echo 
    "<td>
                    [COLOR="
    Red"]<button id='1' name='button'>Add to List</button> 
                    </td>"

                    
                    
    $query "INSERT INTO list(productname) VALUES('$productname')"

                    
    $result mysql_query($query); [/COLOR]                
                    echo 
    "</tr>";
                    
                }
                    echo 
    "</table>";//end table
        
                
    }else{ //if no records found
                
    echo "No records found.";
                    }
                    
                    
                
                
                
    ?>
    The above code creates a button and updates the list table but i want users to be able to add specific products. And then for this product to be removed from the product table and only appear in the list table...
    Last edited by Inigoesdr; 02-25-2012 at 03:52 AM.


  •  

    Posting Permissions

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