Joining arrays

Is there a better way of joining arrays and/or shortening the code:

if($comments==true){
	$checkresult=explode(" ", $id0);
	$sql = "SELECT * FROM ".$dbTable3." WHERE id=";
	$sql .= implode(" OR id=", $checkresult);
	//echo $sql;
	$result = mysql_query($sql) OR exit( 'Error: ' . mysql_error() );
	$id = array();
	$bookTitle = array();	
	$book = array();
	$chapter = array();
	$verse = array();
	while($row = mysql_fetch_array($result)){
		$id[] = $row["id"];
		$bookTitle[] = $row["book_title"];
		$book[] = $row["book"];
		$chapter[] = $row["chapter"];
		$verse[] = $row["verse"];
	}
	$id0=implode("/", $id);
	$bookTitle0=$bookTitle[0];	
	$book0=$book[0];
	$chapter0=$chapter[0];
	$verse0=implode("/", $verse);

	$checkresult=explode(" ", $id1);
	$sql = "SELECT * FROM ".$dbTable3." WHERE id=";
	$sql .= implode(" OR id=", $checkresult);
	//echo $sql;
	$result = mysql_query($sql) OR exit( 'Error: ' . mysql_error() );
	$id = array();
	$bookTitle = array();	
	$book = array();
	$chapter = array();
	$verse = array();
	while($row = mysql_fetch_array($result)){
		$id[] = $row["id"];
		$bookTitle[] = $row["book_title"];
		$book[] = $row["book"];
		$chapter[] = $row["chapter"];
		$verse[] = $row["verse"];
	}
	$id1=implode("/", $id);
	$bookTitle1=$bookTitle[0];	
	$book1=$book[0];
	$chapter1=$chapter[0];
	$verse1=implode("/", $verse);
	$getarray1=Array($comments, $uname, $id0, $bookTitle0, $book0, $chapter0, $verse0, $id1, $bookTitle1, $book1, $chapter1, $verse1);
	var_dump($getarray1);
	$getarray2=Array($date, $ipaddress);
	/*
	for($key=0; $key<count($COLORS); $key++){
		if($_GET["txtarea".$key]!=""){
			$keyword[]=mysql_real_escape_string($_GET["txtarea".$key]);
		}
	}
	*/
	$fields1 = array();
	$sql = "SHOW FIELDS FROM ".$dbTable4;
	$result = mysql_query($sql);
	while ($row = mysql_fetch_array($result)){
		$fields1[]= $row['Field'];
	}
	//print_r($fields1);
	$fields2 = array();
	$sql = "SHOW FIELDS FROM ".$dbTable;
	$result = mysql_query($sql);
	while ($row = mysql_fetch_array($result)){
		$fields2[]= $row['Field'];
	}
	//print_r($fields2);
	$sql = "INSERT INTO ".$dbTable4." (";
	for($farr=1; $farr<count($fields1)-2; $farr++){//$i=1 to avoid blid
		if($fields1[$farr]!=="browser"){
			$sql.= $fields1[$farr];
			if($farr<count($fields1)-3){
				$sql.= ", ";
			}
		}
	}
	$sql .= ") VALUES (\\"";
	for($farr=0; $farr<count($getarray1); $farr++){
		$sql.= $getarray1[$farr];
		if($farr<count($getarray1)-1){
			$sql.= "\\", \\"";
		}
	}
	for($farr=0; $farr<=count($COLORS); $farr++){
		$sql.= $keyword[$farr];
			$sql.= "\\", \\"";
	}
	for($farr=0; $farr<count($getarray2); $farr++){
		$sql.= $getarray2[$farr];
		if($farr<count($getarray2)-1){
			$sql.= "\\", \\"";
		}
	}
	$sql .= "\\")";
	echo "<b>".$sql."</b><br />";
	mysql_query($sql) or die(mysql_error());	
}

Im not 100% sure what your trying to do but from a quick glance looks like your trying to MERGE database tables

Look at the mysql MERGE statement see if that helps you.

Can you post the output of a SHOW CREATE TABLE for the tables concerned?

Is it a permenat merger of tables as a one off operation to merge them or are they being merged (having new rows added to the final table) on a regular basis?