<?php

//Call the configuration file
include('../includes/configuration.php');



//accept some parameters
$cid = '1';
$type_id = '2';
$ptaf = '2';
//$moe = '';

//query one 

$q1 = "SELECT code FROM applicants_nce";


$r1 = mysqli_query($dbc,$q1);

$sn = 0;
								
if(mysqli_num_rows($r1) > 0)
{//if succesfully fetch applicant record

	while($row1 = mysqli_fetch_array($r1, MYSQLI_ASSOC))
	{
		
		
		$q2 = "SELECT id, school_id, department_id  FROM programmes WHERE code = '".$row1['code']."'";
		
        $r2 = mysqli_query($dbc,$q2);
		if($r2)
		{
			$row2 = mysqli_fetch_array($r2, MYSQLI_ASSOC);
			//{
				$q3 = 'UPDATE applicants_nce SET  cart_id = "'.$cid.'", type_id = "'.$type_id.'", programme_type_applied_for = "'.$ptaf.'", school_id = "'.$row2['school_id'].'" ,
				 school_applied_for = "'.$row2['school_id'].'", department_id = "'.$row2['department_id'].'", 
				 department_applied_for = "'.$row2['department_id'].'", programme_id = "'.$row2['id'].'", 
				 programme_applied_for = "'.$row2['id'].'"
				 WHERE id > 4497 AND code = "'.$row1['code'].'"';
					  
				$r3 = mysqli_query($dbc,$q3);
				if($r3)
				{
				
				
				$sn = $sn +1;
				echo $sn.'<br/>';
					  
				}
			//}
		}
		
		
		
	}



}//end of the the codes stil exist



//query 2



///query 3












?>