Jump to content

Loop pulling two rows?


Zepo.

Recommended Posts

<?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?

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.