php code to update tables in phpmyadmin

Discussion in 'PHP' started by student123, Feb 24, 2012.

  1. #1
    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?
     
    student123, Feb 24, 2012 IP
  2. Ambler

    Ambler Active Member

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    Digital Goods:
    1
    #2
    It looks confused. You are modifying phpmyadmin code, right? The phpmyadmin that will be used by different users. I can't imagine a product that requires such functionality.
    Anyway your query needs to execute two commands UPDATE table2 with product from table 1 and then delete product from table 1. If you already has those queries for whole table, just add WHERE statement selecting only the product you need.
     
    Ambler, Feb 24, 2012 IP
  3. student123

    student123 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    this is the code i have so far... this displays a button beside each product (called from the product table) and i want the user to be able to press this button and the specific product should be added tp the list table and removed from the product table, however add the minute when the button is clicked it adds all fiedls from the product table to the list table. i dont have very much coding experience and would appreciate any help!

    <?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>
    <button id='1' name='button'>Add to List</button>
    </td>";

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

    $result = mysql_query($query);


    echo "</tr>";

    }
    echo "</table>";//end table

    }else{ //if no records found
    echo "No records found.";
    }




    ?>
     
    student123, Feb 24, 2012 IP
  4. abettor

    abettor Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    for connection between php and database and updating phpmyadmin tables.
    http://ashwani-blog.blogspot.in/2012/02/database-and-tables.html
     
    abettor, Feb 24, 2012 IP
  5. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #5
    To update only 1 row, use a WHERE clause in your UPDATE statement (which you aren't showing here). BTW, there are no "phpmyadmin tables", they're MySQL tables. phpMyAdmin is just a PHP program you use to manipulate data in a MySQL database.
     
    Rukbat, Feb 25, 2012 IP