PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hello, I currently have a page with a repeated region that has information from a table with a checkbox proceed each line.
My objective is for the admin (on the frontend) to be able to check multiple boxes and when they press the submit button, the information that is stored in the database should be copied to a new database and deleted from the existing database. What I currently have is this:
[/i]
I am not sure how to check whether the checkbox is checked and then where to insert the code (before or after the submit button). I have a basic algorithm but I have no ide how to implement it in PHP. I also know what the SQL statement would be. I have searched and read plenty of books but I just don't know how to put the info together.
$check1 = $_POST['check1'];
//Then check to see if they where checked:
if ($check1 == "selected"){
echo "Checkbox 1 says: I WAS SELECTED";
}
else {
echo "Checkbox 1 says: I WAS NOT SELECTED";
}
When it comes time to Move database entries from one database to another, you will have to SELECT all the data you wish to be moved, store it in variables, then close the original database connection, and connect to the other database, and INSERT the data back in, assuming the tables etc are already created.
Last edited by iknownothing on Wed Aug 01, 2007 11:01 am, edited 1 time in total.
Does this need to go into a loop so that it can check for all the checked data?
There could be 1 listing or 1000 so I would need to check for all of the checked columns.
$check1 = $_POST['check'];
if($check1 == "selected")
{
implement this query (INSERT INTO table SELECT * FROM table1 WHERE ID = 'ID')
implement this query (DELETE FROM table WHERE ID = 'ID')
}
// CONNECT TO OLD DATABASE
// GET STUFF FROM OLD DATABASE
$result = mysql_query("SELECT * FROM old_table");
while($row = mysql_fetch_array($result)) // THIS WILL LOOP TO OBTAIN ALL ENTRIES REQUIRED
{
$variable_1[] = $row['tablerow1']; // THIS SHOULD BE AN ARRAY TO MAKE IT EASIER TO MOVE MASS DATA, BUT I AM UNSURE OF HOW TO DO THIS, I SUGGEST GOOGLING: "SELECT into an array php"
}
mysql_query("DELETE FROM old_table WHERE tablerow1='$variable_1'");
// DISCONNECT FROM DATABASE
// CONNECT TO NEW DATABASE
mysql_query("INSERT INTO new_table (tablerow1) VALUES ('$variable_1')");
Something like that...
Last edited by iknownothing on Wed Aug 01, 2007 11:27 am, edited 1 time in total.
$regions = $_REUQEST['regions'];
foreach ($regions as $id => $checked)
{
if ($checked == 'on')
{
// move $id to the database and delete from current
}
}
There are 10 types of people in this world, those who understand binary and those who don't
I'm hoping that at any one time, the ADMIN could transfer all of the files in or database or just one. Do you think that this could prove to be a problem?
If it gets to be a large database, and for some odd reason, the server crashes mid-transfer, you could lose the lot, the server would most likely have a backup, but who knows how long the restoration stage could take.
The transfers might prove quite slow when it gets large too.