<?php
  session_start();
   
    
    // Load the config file!
    require_once JPATH_SITE."/dbconfig.php";
    // Load the class
    require('training.php');
	//$uname = $_POST['uname'];
	//$_SESSION['user']= $uname;
     
   $training = new training();
   
   
    
    $qeditflag = 0;
	$ceditflag = 0;
	$temp = "";
	if(isset($_GET['op']) and !isset($_POST['save']) ) 
	{
	    $operation = $_GET['op'];
		$rid = $_GET['rid'];
		
		if ($operation == "2")
		{
		    if(isset($_GET['cid']))
			{
			 $training->deletecourse($_GET['cid']);
			}
			else
			{
				$training->deletequestions($rid);
			}
		
		}//if
		else if ($operation == "1")
		{
			if(isset($_GET['cid']))
			{
				 $temp = $training->getcourse($_GET['cid']);
				 $ceditflag = 1;
			}
			else
			{
			 $training->getquestion($rid);
			 $qeditflag = 1;
			}//else
		
		}//else if
	
	}
    
    if(isset($_POST['save'])) 
	{
	
	  $training->insertquestions($_POST['question'],$_POST['option1'],$_POST['option2'],$_POST['option3'],$_POST['option4'],$_POST['answer'],$_POST['course']);
        
       
    }//if
	if(isset($_POST['csave'])) 
	{
	
	  $training->insertcourse($_POST['course_name']);
        
       
    }//if
	if(isset($_POST['qupdate'])) 
	{
	
	  $training->updatequestion($_POST['question'],$_POST['option1'],$_POST['option2'],$_POST['option3'],$_POST['option4'],$_POST['answer'],$_POST['course'],$_POST['qid']);
        
       
    }//if
	if(isset($_POST['cupdate'])) 
	{
	
	  $training->updatecourse($_POST['course_name'],$_POST['course_id']);
        
       
    }//if
    $training->getquestions();
	$training->getcourses();
   
    
?>
<html>
<head>
	<style type="text/css" charset="utf-8">
		
		body#training{
		font-family:Arial,Helvetica,sans-serif; font-size:12px;
		}
	
		span.b_cList{
		font-family:Arial,Helvetica,sans-serif; font-size:16px; font-weight:bold; color:#000;
		}
		/*---------COURSE TABLE---------*/
		table#cList{
		border:1px #cccccc solid;
		}
		
		table#cList tr.cHeading td{
		border-right:1px #fff solid;
		}
		
		table#cList tr.cHeading td.td_last{
		border-right:0px #fff solid;
		}
		
		table#cList tr.tr_two td{
		background:#f0f0f0;
		}
		
		table#cList tr{
		height:25px
		}
		
		tr.cHeading{
		background:#025681;
		}
		
		td.cTitle{
		font-family:Arial,Helvetica,sans-serif; font-size:14px; font-weight:bold; color:#fff; padding-left:12px;
		}
		
		td.cName{
		font-family:Arial,Helvetica,sans-serif; font-size:12px; font-weight:bold; color:#000; padding-left:12px;
		}
		
		td.cDelete, td.cEdit{
		font-family:Arial,Helvetica,sans-serif; font-size:12px; color:#000;
		}
		
		/*---------QUESTION TABLE---------*/
		table#qList{
		border:1px #cccccc solid;
		}
		
		table#qList tr.qHeading td{
		border-right:1px #fff solid;
		}
		
		table#qList tr.qHeading td.td_last{
		border-right:0px #fff solid;
		}
		
		table#qList tr.tr_two td{
		background:#f0f0f0;
		}
		
		table#qList tr{
		height:25px
		}
		
		tr.qHeading{
		background:#025681;
		}
		
		td.qTitle{
		font-family:Arial,Helvetica,sans-serif; font-size:14px; font-weight:bold; color:#fff; padding-left:12px;
		}
		
		td.qName{
		font-family:Arial,Helvetica,sans-serif; font-size:12px; font-weight:bold; color:#000; padding-left:12px;
		}
		
		td.qDelete, td.qEdit{
		font-family:Arial,Helvetica,sans-serif; font-size:12px; color:#000;
		}
		
		td.qType{
		font-family:Arial,Helvetica,sans-serif; font-size:12px; color:#000; padding-left:12px;
		}
		
		table#qList td.cType{
		font-family:Arial,Helvetica,sans-serif; font-size:14px; color:#fff; font-weight:bold; padding-left:12px;
		}
	</style>
</head>
<body id="training">
<p style="font-family:Arial,Helvetica,sans-serif; font-size:22px; font-weight:bold; color:#0B55C4;"><img src="components/com_trainingform/t_icon.gif" width="42" height="37" />&nbsp;Rexperts Training</p>
<!---------CREATE COURSE START--------->
<span class="b_cList">Create Course</span>
<hr>
<br />
<form name="training" id="training" method='post' action="<?php echo SERVER_ROOT;?>administrator/index.php?option=com_trainingform">
	<table border="0">

		<tr>
			<td>Course Name</td>
			<td><input type="text" name="course_name" id="course_name" size='20'/></td>
		</tr>

		<tr>
			<td><input type="submit" name='csave' value="save" /></td>
		</tr>
	</table>
</form>
<br />
<!---------CREATE COURSE END--------->
<span class="b_cList">Course List</span>
<hr>
<table id="cList" border="0" cellpadding="1" cellspacing="1" width="100%" >
	<tr class="cHeading">
		
		<td class="cTitle">
			Course Title
		</td>
		
		<td align="center">&nbsp;
			
		</td>
		<td class="td_last" align="center">&nbsp;
			
		</td>
		
	
	</tr>
<?php
 if(count($training->courselist)) {
            // message loop
            for($i=0;$i<count($training->courselist);$i++) {
                ?>
	<tr class="tr_two">
		<td class="cName">
			<?php echo $training->courselist[$i]['course_name']; ?>
		
		</td>
		
		
		<td class="cDelete" align="center">
		    <a href="<?php $_SERVER['PHP_SELF']?>index.php?option=com_trainingform&op=2&cid=<?php echo $training->courselist[$i]['id']; ?>" > Delete </a>
		</td>
		
		<td class="cEdit" align="center">
		    <a href="<?php $_SERVER['PHP_SELF']?>index.php?option=com_trainingform&op=1&cid=<?php echo $training->courselist[$i]['id']; ?>" > Edit </a>
		</td>
		
	
	</tr>
<?php
      }//for
	}//if

?>
</table>

<?php
    if ($ceditflag == 0 and $qeditflag == 0)
	{
	
?>
    <br />

<?php
  }//if
  else if ($ceditflag == 1 and $qeditflag == 0)
  {
  
?>
<form name="training" id="training" method='post' action="<?php echo SERVER_ROOT;?>administrator/index.php?option=com_trainingform">
<input type="hidden" name="course_id" id="course_id" value="<?php echo $training->clist['id'];?>"
<table border="0">

<tr>
	<td>Course Name</td>
	
	<td><input type="text" name="course_name" id="course_name" value="<?php echo $training->clist['course_name'];?>" size='20'/></td>
</tr>

<tr>
	<td><input type="submit" name='cupdate' value="Update" /></td>
	<td><input type="Button" value="Cancel" onClick="parent.location='<?php echo SERVER_ROOT; ?>administrator/index.php?option=com_trainingform'"/></td>
   
</tr>
</table>
</form>
<?php
  }//else

?>

<p align="justify">
<br />
<span class="b_cList">Create Question</span>
<hr>
<?php


    if ($qeditflag == 0 and $ceditflag == 0)
	{
	
?>
    
<form name="training" id="training" method='post' action="<?php echo SERVER_ROOT;?>administrator/index.php?option=com_trainingform">
<table border="0">
<tr>
<td>Select Course:</td>
	<td>
	  
		<select id='course' name='course'>
		  <?php
			if(count($training->courselist)) {
			for($j=0;$j<count($training->courselist);$j++) {
			
			
		?>
		   <option value='<?php echo $training->courselist[$j]['id']; ?>'><?php echo $training->courselist[$j]['course_name']; ?></option>
		<?
			
			
			}//for
				
			
			
			
			}//if
		  
		  ?>
		  </select>
	
	
	</td>


</tr>

<tr>
	<td>Question1</td>
	<td><textarea name='question' id='question' rows='2' cols='50'></textarea></td>
</tr>
<tr>
	<td>Option1</td>
	<td><input type="text" name="option1" id="option1" size='20' ></td>
</tr>
<tr>
	<td>Option2</td>
	<td><input type="text" name="option2" id="option2" size='20'></td>
</tr>
<tr>
	<td>Option3</td>
	<td><input type="text" name="option3" id="option3" size='20'></td>
</tr>
<tr>
	<td>Option4</td>
	<td><input type="text" name="option4" id="option4" size='20'></td>
</tr>
<tr>
	<td>Answer</td>
	<td><input type="text" name="answer" id="answer" size='5'></td>
</tr>


<tr>
	<td><input type="submit" name='save' value="save" /></td>
    <td><input type="reset" value="Clear form" /></td>
</tr>
</table>
</form>
<?php
}
  elseif ($qeditflag == 1)
{

  
?>
<form name="training" id="training" method='post' action="<?php echo SERVER_ROOT;?>administrator/index.php?option=com_trainingform">
<input type="hidden" id="qid" name="qid" value="<?php echo $training->pquestion['id']; ?>" />
<table border="0">
<tr>
<td>Select Course1:</td>
	<td>
	  
		<select id='course' name='course'>
		  <?php
			if(count($training->courselist)) {
			for($j=0;$j<count($training->courselist);$j++) {
			
			
		?>
		  <?php  if ( $training->pquestion['courseid']  == $training->courselist[$j]['id'] )
				{
		  ?>
		   <option value='<?php echo $training->courselist[$j]['id']; ?>' selected><?php echo $training->courselist[$j]['course_name']; ?></option>
		<?
		  }//if
		  else
		  {
		  
	?>
		<option value='<?php echo $training->courselist[$j]['id']; ?>'><?php echo $training->courselist[$j]['course_name']; ?></option>
	
	<?
	     }//else
			
			
			}//for
				
			
			
			
			}//if
		  
		  ?>
		  </select>
	
	
	</td>


</tr>
<tr>
	<td>Question</td>
	<td><textarea name='question' id='question' rows='2' cols='50'><?php echo $training->pquestion['question']; ?></textarea></td>
</tr>
<tr>
	<td>Option1</td>
	<td><input type="text" name="option1" id="option1" size='20' value="<?php echo $training->pquestion['option1'];?>" ></td>
</tr>
<tr>
	<td>Option2</td>
	<td><input type="text" name="option2" id="option2" size='20' value="<?php echo $training->pquestion['option2'];?>"></td>
</tr>
<tr>
	<td>Option3</td>
	<td><input type="text" name="option3" id="option3" size='20' value="<?php echo $training->pquestion['option3'];?>"></td>
</tr>
<tr>
	<td>Option4</td>
	<td><input type="text" name="option4" id="option4" size='20' value="<?php echo $training->pquestion['option4'];?>"></td>
</tr>
<tr>
	<td>Answer</td>
	<td><input type="text" name="answer" id="answer" size='5' value="<?php echo $training->pquestion['answer'];?>"></td>
</tr>


<tr>
	<td><input type="submit" name='qupdate' value="Update" /></td>
    <td><input type="Button" value="Cancel" onClick="parent.location='<?php echo SERVER_ROOT; ?>administrator/index.php?option=com_trainingform'"/></td>
</tr>
</table>
</form>
<?php
  }//else

?>
<br />
<span class="b_cList">Question List</span>
<hr>
<table id="qList" border="0" cellpadding="1" cellspacing="1" width="100%">
	<tr class="qHeading">
		
		<td class="qTitle">
			 Questions
		</td>
		<td class="cType">
			 Course Type
		</td>
		<td>&nbsp;
			
		</td>
		<td>&nbsp;
			
		</td>
	
	</tr>
<?php
 if(count($training->questionlist)) {
            // message loop
            for($i=0;$i<count($training->questionlist);$i++) {
                ?>
	<tr class="tr_two">
		<td class="qName">
			<?php echo $training->questionlist[$i]['question']; ?>
		
		</td>
		<td class="qType">
		<?php
				if(count($training->courselist)) {
					for($j=0;$j<count($training->courselist);$j++) {
					   if($training->courselist[$j]['id'] == $training->questionlist[$i]['courseid'] )
					   {
						 echo  $training->courselist[$j]['course_name'];
						 break;
					
					   }
					
					}//for
				}//if
		
		?>
		  
		
			&nbsp;
		
		</td>
		
		
		<td class="qDelete" align="center">
		    <a href="<?php $_SERVER['PHP_SELF']?>index.php?option=com_trainingform&op=2&rid=<?php echo $training->questionlist[$i]['id'] ?>" > Delete </a>
		</td>
		<td class="qEdit" align="center">
		    <a href="<?php $_SERVER['PHP_SELF']?>index.php?option=com_trainingform&op=1&rid=<?php echo $training->questionlist[$i]['id'] ?>" > Edit </a>
		</td>
		
	
	</tr>
<?php
      }//for
	}//if

?>
</table>




</body>
</html>

above program they have error ........Parse error: parse error in C:\wamp\www\joomla\new\administrator\components\com_coursemap\admin.coursemap.php on line 219

On lines 232 AND 236 you have: <a href="<?php $_SERVER['PHP_SELF']?>index.php... change them to: <a href="<?php [B]echo [/B]$_SERVER['PHP_SELF'][B];[/B]?>index.php...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.