Jump to content

[SOLVED] Move Table row to a new table


JasonO

Recommended Posts

Hey

 

I have a database of some information and it is in a table row by row.

 

I have a page that displays these in a table row by row, however I want to have a link to the side of each row allowing me to transfer that row to a new table.

 

How would I do this? I've tried a few ways but that was a random guess and didn't work.

 

Thanks for your help guys (and girls).

 

Jason

Link to comment
https://forums.phpfreaks.com/topic/48486-solved-move-table-row-to-a-new-table/
Share on other sites

What you want to do isn't hard (although random guessing may take an infinite amount of time).  Before we tell you how, why not tell us why you want them in another table instead of simply changing a flag in the existing table to indicate 'where' any record belongs?

Assume you have a primary key on that table: 'id'

So you would print your link like this:

<a href="transferToOtherTable.php?theid=<?php echo mysql_result($qry, $loop_count, 'id'); ?>">Click Here To Transfer</a>

 

So in your transferToOtherTable.php:

//get the id
if(isset($_REQUEST['theid'])){
    $qry = mysql_query("SELECT * FROM the_table WHERE id=" . $_REQUEST['theid']);
    So you get all the data and put it into anther new table. Hope you know the sql for this.
}

Hey

 

What I have is a database of new requests, and once seen to and accepted i want to move them to a new table on the page. I want 2 seperate tables in my mysql database.

 

I try what you have posted and get back with a result. I have a seperate id for each request, and I already used a similar meathod that you posted to delete, I just don't know how you get all the info and move it.

 

Update : Ok with the information you got, I guess I just select the data with the id, then insert it then remove it? I give it a go :P

 

Thanks for your help :)

 

Jason

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.