<?php 
	
	/*
	 *  set HOST,USER,PASSWORD & DATABASE
	 */
	include('config.php');
	$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
	if(!$link) 
	{
		die('Failed to connect to server: ' . mysql_error());
	}
	
	//Select database
	$db = mysql_select_db(DB_DATABASE);
	if(!$db) 
	{
		die("Unable to select database");
	}
	
	$reg_name = $_POST['reg_name'];
	$reg_college = $_POST['reg_college'];
	$reg_email = $_POST['reg_email'];
	$reg_mobile = $_POST['reg_mob'];
	$reg_id = $_POST['reg_id'];
	$reg_events = $_POST['events'];
	$col_id = $_POST['col_id'];
	
	$query = "UPDATE  registration SET reg_name='$reg_name',reg_email='$reg_email',reg_college= '$reg_college',reg_mobile='	$reg_mobile',reg_events='$reg_events',col_id='$col_id' where reg_id=$reg_id";
	
	mysql_query($query) or die('Invalid query: ' . mysql_error());
	
	echo $reg_id;
	echo "<br/>";
	echo "The events registered are";
	$query ="SELECT * FROM registration WHERE reg_id='$reg_id'";
	$choice = mysql_query($query);
	while ($row = mysql_fetch_array($choice, MYSQL_ASSOC))
	{
			$level=$row['reg_events'];
	}
	$level2= explode(",",$level);
	$result =count($level2);
	$i=0;
	while($i<$result)
	{
		$query ="SELECT * FROM events WHERE event_id='$level2[$i]'";
		$choice = mysql_query($query);
		while ($row = mysql_fetch_array($choice, MYSQL_ASSOC))
		{
			$events=$row['event_name'];
		}
		echo "<br/>";
		echo $events." &nbsp; E".$level2[$i];
		$i++;
	}

?>