JasonO Posted April 24, 2007 Share Posted April 24, 2007 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 More sharing options...
AndyB Posted April 24, 2007 Share Posted April 24, 2007 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? Link to comment https://forums.phpfreaks.com/topic/48486-solved-move-table-row-to-a-new-table/#findComment-237098 Share on other sites More sharing options...
xenophobia Posted April 24, 2007 Share Posted April 24, 2007 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. } Link to comment https://forums.phpfreaks.com/topic/48486-solved-move-table-row-to-a-new-table/#findComment-237099 Share on other sites More sharing options...
JasonO Posted April 24, 2007 Author Share Posted April 24, 2007 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 Thanks for your help Jason Link to comment https://forums.phpfreaks.com/topic/48486-solved-move-table-row-to-a-new-table/#findComment-237105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.