<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright EB Dynamics, Inc., Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 1/11/2011	ELL
// 
//

function copy_table($src_table, $dest_table, $link, $database)
	{
		$query = "TRUNCATE TABLE `" . $dest_table;
		$result = mysql_query($query, $link);
			
		$query = "SELECT * FROM " . $src_table;
		$result = mysql_query($query, $link);
		while ($row = mysql_fetch_array($result))
		{
			$sql = "INSERT INTO " . $dest_table . " SET ";
			$query2 = "SHOW COLUMNS FROM " . $src_table . " FROM " . $database;
			$result2 = mysql_query($query2, $link);
			while ($column = mysql_fetch_array($result2))
			{
				if ($column['Field'] != "id")
				{
					if (strpos($sql, "=")) 
						$sql .= ", ";
					$field = $column['Field'];
					$sql .= "`" . $field . "` = '" . addslashes($row[$field]) . "'";
				}
			}
//			echo "sql: $sql\n<br><br>\n";
			$result3  = mysql_query($sql, $link);
		}
	}
	
?>