roles[0]; if($current_user_role=='administrator' || $current_user_role=='teacher') { wpsp_topbar(); wpsp_sidebar(); wpsp_body_start(); $filename = WPSP_PLUGIN_PATH .'includes/wpsp-studentList.php'; if( isset( $_GET['tab'] ) && $_GET['tab'] == 'addstudent' ) { if($current_user_role=='administrator'){ $label = __( 'Add New Student', 'wpschoolpress'); $filename = WPSP_PLUGIN_PATH .'includes/wpsp-studentForm.php'; } } else if( isset($_GET['id']) && is_numeric($_GET['id']) ) { if($current_user_role=='administrator' || $current_user_role=='teacher') { $label = __( 'Update Student', 'wpschoolpress'); $filename = WPSP_PLUGIN_PATH .'includes/wpsp-studentProfile.php'; } } else if( isset( $_POST['ClassID'] ) && empty( $_POST['ClassID'] ) ) { $label = esc_html('List Of Unassigned Students','wpschoolpress'); } else if( isset( $_POST['ClassID'] ) && $_POST['ClassID']=='all' ) { $label = esc_html('List Of All Students','wpschoolpress'); } else if( isset( $_POST['ClassID'] ) && !empty( $_POST['ClassID'] ) ){ $class_table = $wpdb->prefix."wpsp_class"; $sel_class = $wpdb->prepare( "SELECT * FROM $class_table WHERE cid LIKE %d;",'%' . $wpdb->esc_like( $_POST['ClassID'] ) . '%' ); $label = 'List of class ' .esc_html($sel_class). ' Students'; } else { $label = esc_html('List Of All Students','wpschoolpress'); } include_once ( $filename ); if(isset($_GET['tab'])){ if($_GET['tab'] != 'addstudent' ) { do_action('wpsp_student_import_html'); } } wpsp_body_end(); wpsp_footer(); }else if($current_user_role=='parent') { /* Parents can View their children's class students */ wpsp_topbar(); wpsp_sidebar(); wpsp_body_start(); global $wpdb; $parent_id = intval($current_user->ID); $student_table = $wpdb->prefix."wpsp_student"; $class_table = $wpdb->prefix."wpsp_class"; $users_table = $wpdb->prefix."users"; // $students = $wpdb->get_results("select st.wp_usr_id, st.class_id, st.s_fname AS full_name,cl.c_name from $student_table st LEFT JOIN $class_table cl ON cl.cid=st.class_id where st.parent_wp_usr_id='".esc_sql($parent_id)."'"); $students = $wpdb->get_results($wpdb->prepare("SELECT st.wp_usr_id, st.class_id, st.s_fname AS full_name,cl.c_name FROM $student_table st LEFT JOIN $class_table cl ON cl.cid=st.class_id WHERE st.parent_wp_usr_id = %d",$parent_id)); $child=array(); foreach($students as $childinfo){ $child[]=array('student_id'=>$childinfo->wp_usr_id,'name'=>$childinfo->full_name,'class_id'=>$childinfo->class_id,'class_name'=>$childinfo->c_name); } if( count( $child ) > 0 ) { ?>
get_row("select a.*,b.c_name,CONCAT_WS(' ', a.s_fname, a.s_mname, a.s_lname ) AS full_name,d.user_email from $student_table a LEFT JOIN $class_table b ON a.class_id=b.cid LEFT JOIN $users_table d ON d.ID=a.wp_usr_id where a.wp_usr_id='".esc_sql($sid)."'"); $stinfo = $wpdb->get_results($wpdb->prepare("SELECT a.*,b.c_name,CONCAT_WS(' ', a.s_fname, a.s_mname, a.s_lname ) AS full_name,d.user_email FROM $student_table a LEFT JOIN $class_table b ON a.class_id=b.cid LEFT JOIN $users_table d ON d.ID=a.wp_usr_id WHERE a.wp_usr_id = %d",$sid)); if (is_numeric($stinfo->class_id)){ $classIDArray[] = $stinfo->class_id; }else{ $classIDArray = unserialize($stinfo->class_id); } $classname_array = []; $classIDArray_Sanitiz = array_map('intval',$classIDArray); foreach ($classIDArray_Sanitiz as $id ) { $id = esc_sql($id); // $clasname = $wpdb->get_var("SELECT c_name FROM $class_table where cid='$id'"); $clasname = $wpdb->get_results($wpdb->prepare("SELECT c_name FROM $class_table WHERE cid = %d",$id)); $classname_array[] = $clasname; } if(!empty($stinfo)) { ?>

full_name); ?>

s_rollno); ?>
s_gender); ?>
s_dob)); ?>
s_doj)); ?>
s_paddress); ?>
s_pcountry); ?>
s_pzipcode); ?>
user_email); ?>
s_phone); ?>
s_bloodgrp); ?>
ID); $student_table=$wpdb->prefix."wpsp_student"; $class_table=$wpdb->prefix."wpsp_class"; // $student=$wpdb->get_row("select st.class_id, CONCAT_WS(' ', st.s_fname, st.s_mname, st.s_lname ) AS full_name,cl.c_name from $student_table st LEFT JOIN $class_table cl ON cl.cid=st.class_id where st.wp_usr_id='".esc_sql($student_id)."'"); $student = $wpdb->get_row($wpdb->prepare("SELECT st.class_id, CONCAT_WS(' ', st.s_fname, st.s_mname, st.s_lname ) AS full_name,cl.c_name FROM $student_table st LEFT JOIN $class_table cl ON cl.cid=st.class_id WHERE st.wp_usr_id = %d",$student_id)); ?>

class_id; if( isset( $student->c_name ) && !empty( $student->c_name ) ) echo "Your Current Class is".esc_html( $student->c_name,'wpschoolpress' ); ?>

get_results("select wp_usr_id, class_id, CONCAT_WS(' ', s_fname, s_mname, s_lname ) AS full_name,parent_wp_usr_id, CONCAT_WS(' ', p_fname, p_mname, p_lname ) AS p_full_name, CONCAT_WS(' ', s_paddress, s_pcity, s_pcountry ) AS peraddress, s_rollno from $student_table"); $sno=1; $jsonArray=[]; foreach($cl_students as $cl_st) { $jsonArray=[]; $jsonvalue1 = false; // initialize $jsondata = $cl_st->class_id; if (is_numeric($jsondata)){ $jsonArray[] = $jsondata; $jsonvalue1 = $jsondata; }else{ $jsonArray = unserialize($jsondata); if(!empty($jsonArray)){ $jsonvalue1 = in_array($class_id, $jsonArray); } } if(!empty($jsonvalue1)){ ?>
#
s_rollno);?> full_name);?> p_full_name);?> peraddress);?>