File: /var/www/nclive/backend/sp_exampage.php_old
<?php
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
include "config.php";
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$exam=$_REQUEST['slug'];
echo $query="SELECT t1.exam_id,t1.exam_name,t1.url_slug,t1.exam_year,t1.total_vacancy,t1.total_time,t1.total_marks,t1.exam_mode,t1.negative_marking,t1.other_info,t1.other_info_tabname,t1.cat_id,t1.qualification_desc,e.img_icon,t1.age_id,t3.age,t1.age_to,t1.age_from,t1.age_desc,t4.quali_name,t1.physical,t1.display_order,t1.fee_desc,t1.exam_summary,st.image_icon,t1.important_notes, se.title,se.keywords,se.meta_description,se.meta_keywords,t1.status,t1.off_web_link FROM sp_exam as t1
LEFT JOIN sp_age_limit as t3 on t1.age_id=t3.age_lim_id
LEFT JOIN sp_qualification as t4 ON t1.qualification_id=t4.qualification_id
LEFT JOIN sp_states as st on st.state_id=t1.state_id
LEFT JOIN sp_exam_category as e on e.cat_id=t1.cat_id
LEFT JOIN sp_pages_seo as se on se.exam_id=t1.exam_id
WHERE t1.url_slug='$exam'";
$sql=$db->prepare($query);
$sql->execute();
$mainarray=array();
while($row=$sql->fetch()){
$exam_id=$row['exam_id'];
if($row['cat_id']==0){
$img='/images/'. $row['image_icon'];
}
else{
$img='/images/'. $row['img_icon'];
}
$title = $row['title'];
$keywords = $row['keywords'];
$meta_description=$row['meta_description'];
$meta_keywords=$row['meta_keywords'];
$summary=$row['exam_summary'];
$important_notes=$row['important_notes'];
$examname=$row['exam_name'];
$exam_year=$row['exam_year'];
$vacancy=$row['total_vacancy'];
$total_time= $row['total_time'];
$total_marks= $row['total_marks'];
$exam_mode= $row['exam_mode'];
$neg_mark= $row['negative_marking'];
$other_info= $row['other_info'];
$tab= $row['other_info_tabname'];
$agelimit=$row['age'];
$age_to=$row['age_to'];
$age_from=$row['age_from'];
$agedesc = $row['age_desc'];
$qualidesc=$row['qualification_desc'];
$quali = $row['quali_name'];
$phy=$row['physical'];
$fee=$row['fee_desc'];
$off_web_link=$row['off_web_link'];
echo $query2="SELECT t1.exam_id,t1.entity_id,t1.display_text,t1.display_text_dates,t1.links,t1.date_type,t1.date,t2.name,t1.status FROM sp_exam_links as t1
LEFT JOIN sp_exam_entity as t2 on t2.id=t1.entity_id WHERE exam_id='$exam_id' AND t1.date!='' order by t2.display_order asc";
$sql2=$db->prepare($query2);
$sql2->execute();
$mainSub = array();
while($row2=$sql2->fetch()){
$displaytext=$row2['name'];
$displaytextdates=$row2['display_text_dates'];
$desc=$row2['display_text'];
$date_type=$row2["date_type"];
$dates=$row2["date"];
$date="";
if($date_type=="N"){
$d=explode(",",$dates);
$e=array();
for($p=0;$p<count($d);$p++){
$new_date = date('d-m-Y', strtotime($d[$p]));
$e[]=$new_date;
$date=implode(" ,",$e);
}}
if($date_type=="FT"){
$dd=explode(",",$dates);
$date1 = date('d-m-Y', strtotime($dd[0]));
$date2 = date('d-m-Y', strtotime($dd[1]));
$date=' From '.$date1.' To '.$date2;
}
$main=array("display_text"=>$displaytext,"date"=>$date,"display_text_dates"=>$displaytextdates);
$mainSub[]=$main;
}
echo $query3="SELECT tab1.id,tab1.name,tab1.status,tab2.links,tab2.display_text,tab2.description,tab2.status,tab2.date FROM sp_exam_entity as tab1
LEFT JOIN sp_exam_links As tab2 ON tab2.entity_id=tab1.id where tab2.exam_id='$exam_id' AND tab2.links!='' order by tab1.display_order asc";
$sql3=$db->prepare($query3);
$sql3->execute();
$mainSub2 = array();
while($row3=$sql3->fetch()){
$entity_id=$row3['id'];
$enti=$row3['name'];
$display=$row3['display_text'];
$descrip=$row3['description'];
$links=$row3['links'];
$dates=$row3['date'];
$statuss=$row3['status'];
$main2=array("entity_id"=>$entity_id,"enti_name"=>$enti,"text"=>$display,"description"=>$descrip,"link"=>$links,"date"=>$dates,"status"=>$statuss);
$mainSub2[]=$main2;
}
echo $query4="SELECT t6.exam_id, t6.subject_name, t6.no_of_question,t6.marks_for_subject,t6.exam_id, t6.subject_name, t6.marks_for_subject, t6.date_added, t6.status FROM sp_exam_pattern as t6 WHERE t6.exam_id='$exam_id'";
$sql4=$db->prepare($query4);
$sql4->execute();
$mainSub3 = array();
while($row4=$sql4->fetch()){
$sub=$row4['subject_name'];
$que=$row4['no_of_question'];
$marks=$row4['marks_for_subject'];
$d=$row4['date_added'];
$status3=$row4['status'];
$main3=array("subject"=>$sub,"question"=>$que,"marks"=>$marks,"date"=>$d,"status"=>$status3);
$summarks += $row4['marks_for_subject'];
$summquestion +=$row4['no_of_question'];
$mainSub3[]=$main3;
}
echo $query5="SELECT exam_id, st_sc, obc, gen, women, ex_servicemen, others,year, status FROM sp_exam_cutoff WHERE exam_id='$exam_id'";
$sql5=$db->prepare($query5);
$sql5->execute();
$mainSub4 = array();
while($row5=$sql5->fetch()){
$year=$row5['year'];
$st_sc=$row5['st_sc'];
$obc=$row5['obc'];
$gen=$row5['gen'];
$women=$row5['women'];
$ex_servicemen=$row5['ex_servicemen'];
$others=$row5['others'];
$status=$row5['status'];
$main4=array("year"=>$year,"st/sc"=>$st_sc,"obc"=>$obc,"general"=>$gen,"women"=>$women,"ex_servicemen"=>$ex_servicemen,"other"=>$others,"status"=>$status);
$mainSub4[]=$main4;
}
echo $query6="SELECT id, exam_id, type_id, type_name, gen, obc, sc, st, ebc, wbc, total_vac, age_limit, eligibility FROM sp_vacancy_detail WHERE exam_id='$exam_id'";
$sql6=$db->prepare($query6);
$sql6->execute();
$mainSub5 = array();
while($row6=$sql6->fetch()){
$id= $row6['id'];
$exam= $row6['exam_id'];
$type= $row6['type_id'];
$typename= $row6['type_name'];
$gen= $row6['gen'];
$obc= $row6['obc'];
$sc= $row6['sc'];
$st= $row6['st'];
$ebc= $row6['ebc'];
$wbc= $row6['wbc'];
$total= $row6['total_vac'];
$age= $row6['age_limit'];
$eligibility= $row6['eligibility'];
$main5=array("id"=>$id,"exam_id"=>$exam,"type"=>$type,"type_name"=>$typename,"gen"=>$gen,"obc"=>$obc,"sc"=>$sc,"st"=>$st,"ebc"=>$ebc,"wbc"=>$wbc,"total_vac"=>$total,"age_limit"=>$age,"eligibility"=>$eligibility);
$mainSub5[]=$main5;
}
$query7="SELECT id, exam_id, gender, categories, height,chest, race, time, long_jump, high_jump, short_put, chances, status, id ,exam_id, gender, categories,height, chest, race, time, long_jump, high_jump, short_put, chances,status FROM sp_physical_eligibility WHERE exam_id='$exam_id'";
$sql7=$db->prepare($query7);
$sql7->execute();
$mainSub6 = array();
while($row7=$sql7->fetch()){
$id= $row7['id'];
$exam= $row7['exam_id'];
$gen= $row7['gender'];
if($gen=='M'){ $gender="Male";}
else if($gen=='F'){ $gender="Female";}
else{ $gender="others";}
$categories= $row7['categories'];
$height= $row7['height'];
$chest= $row7['chest'];
$race= $row7['race'];
$time= $row7['time'];
$long_jump= $row7['long_jump'];
$high_jump= $row7['high_jump'];
$short_put= $row7['short_put'];
$chances= $row7['chances'];
$main6=array("id"=>$id,"exam_id"=>$exam,"gender"=>$gender,"categories"=>$categories,"height"=>$height,"chest"=>$chest,"race"=>$race,"time"=>$time,"long_jump"=>$long_jump,"high_jump"=>$high_jump,"short_put"=>$short_put,"chances"=>$chances);
$mainSub6[]=$main6;
}
$array=array("title"=>$title,"keywords"=>$keywords,"meta_description"=>$meta_description,"meta_keywords"=>$meta_keywords,"image"=>$img,"exam_name"=>$examname,"age_to"=>$age_to,"age_from"=>$age_from,"exam_year"=>$exam_year,"exam_summary"=>$summary,"off_web_link"=>$off_web_link,"important_notes"=>$important_notes,"vacancy"=>$vacancy,"total_time"=>$total_time,"total_marks"=>$total_marks,"exam_mode"=>$exam_mode,"negative_marking"=>$neg_mark, "other_info"=>$other_info,"tabname"=>$tab,"age_limit"=>$agelimit,"age_desc"=>$agedesc,"qualification_desc"=>$qualidesc,"quali"=>$quali,"fee_description"=>$fee,"physical"=>$phy,"pattern_total_marks"=>$summarks,"pattern_total_question"=> $summquestion,"dates"=>$mainSub,"links"=>$mainSub2,"pattern"=>$mainSub3,"patterntotals"=>$TotalQusMarks,"cutoff"=>$mainSub4,"vacant"=>$mainSub5,"physical_eligibility"=>$mainSub6);
$mainarray[]=$array;
}
print_r($array);
//echo json_encode($mainarray);
// print_r($mainarray);
?>