dezkit Posted July 19, 2010 Share Posted July 19, 2010 huh? what is my script not doing right for you? - It takes two random rows - while its looping through the rows it's... -- inserting the data to another table -- deleting the data in the original table Quote Link to comment Share on other sites More sharing options...
Zepo. Posted July 20, 2010 Author Share Posted July 20, 2010 Yes but its inserting the two first rows in two other rows when it should insert the first two rows into one row. Here a picture i made Quote Link to comment Share on other sites More sharing options...
dezkit Posted July 20, 2010 Share Posted July 20, 2010 <?php $query1 = "SELECT * FROM `example1` LIMIT 0 , 2"; $result1 = mysql_query($query1) or die(mysql_error()); $i=1; $rows = array( ); while($row1 = mysql_fetch_array($result1)){ $rows[$i]["name"] = $row1["name"]; $rows[$i]["id"] = $row1["id"]; $i++; } $query2 = "INSERT INTO example2 (id_1,name_1,id_2,name_2) VALUES('".$rows[1]["id"]."','".$rows[1]["name"]."','".$rows[2]["id"]."','".$rows[2]["name"]."' ) "; $result2 = mysql_query($query2) or die(mysql_error()); ?> Is this what you needed? Quote Link to comment Share on other sites More sharing options...
Zepo. Posted July 20, 2010 Author Share Posted July 20, 2010 Yes i think i can work with that thank you so much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.