I'm trying to update my DB with all the data from another table. The problem is the loop only uses the first row in temp, but does its job too many time.

Table temp has 1000 rows.

Table products ends up with 5008 identical rows (apart from primary key). All data is from row 1 of temp.

PHP Code:
public function insertBloodyProducts(){
$q "SELECT * FROM ".DB_PREFIX."temp";
$result $this->query($q)){
$row $this->fetch_assoc($result);
$cleanURL preg_replace('/[^a-zA-Z0-9]/i','-',$row['tempName']);
$cleanURL preg_replace('/ /i','-',$cleanURL);
$categories = array("161"); //Array for future additions
$data = array(...);
$q1 $this->insertProductQuery($data);

$result1 $this->query($q1);


This has been driving me crazy. Can anyone see where I'm going wrong?