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 Link to comment https://forums.phpfreaks.com/topic/207783-loop-pulling-two-rows/page/2/#findComment-1088263 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 Link to comment https://forums.phpfreaks.com/topic/207783-loop-pulling-two-rows/page/2/#findComment-1088410 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? Link to comment https://forums.phpfreaks.com/topic/207783-loop-pulling-two-rows/page/2/#findComment-1088418 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. Link to comment https://forums.phpfreaks.com/topic/207783-loop-pulling-two-rows/page/2/#findComment-1088459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.