Trying to work out on a Wordpress plugin which has to do with School Management stuff. Unfortunately to me the sellers do not reply or offer support which made me look a little into the code.
The thing I want to do is that, whenever a student is Absent or present or even late, the parent MUST read the reason behind it.
This is the teacher's attendence panel:
Teacher Panel
Now, whenever the parent wants to check his Child,this is what he sees:
Parent panel
As you can see, there's a Comment which was added by me hoping I could grab out the $comment also but with failure.
Adding the following snippet:
echo '<td>';
echo $comment;
echo '</td>';
didn't help at all.
The following one is the code:
<?php
$obj_mark = new Marks_Manage();
?>
<script>
$(document).ready(function() {
$('#student_list').DataTable({
responsive: true
});
} );
</script>
<!-- POP up code -->
<div class="popup-bg">
<div class="overlay-content">
<div class="result"></div>
<div class="view-parent"></div>
<div class="view-attendance"></div>
</div>
</div>
<?php if(isset($_REQUEST['attendance']) && $_REQUEST['attendance'] == 1)
{
?>
<div class="panel-body panel-white">
<ul class="nav nav-tabs panel_tabs" role="tablist">
<li class="active">
<a href="#child" role="tab" data-toggle="tab">
<i class="fa fa-align-justify"></i> <?php _e('Attendance', 'school-mgt'); ?></a>
</a>
</li>
</ul>
<div class="tab-content">
<div class="panel-body">
<form name="wcwm_report" action="" method="post">
<input type="hidden" name="attendance" value=1>
<input type="hidden" name="user_id" value=<?php echo $_REQUEST['student_id'];?>>
<div class="form-group col-md-3">
<label for="exam_id"><?php _e('Strat Date','school-mgt');?></label>
<input type="text" class="form-control" name="sdate" value="<?php if(isset($_REQUEST['sdate'])) echo $_REQUEST['sdate'];else echo date('Y-m-d');?>">
</div>
<div class="form-group col-md-3">
<label for="exam_id"><?php _e('End Date','school-mgt');?></label>
<input type="text" class="form-control" name="edate" value="<?php if(isset($_REQUEST['edate'])) echo $_REQUEST['edate'];else echo date('Y-m-d');?>">
</div>
<div class="form-group col-md-3 button-possition">
<label for="subject_id"> </label>
<input type="submit" name="view_attendance" Value="<?php _e('Go','school-mgt');?>" class="btn btn-info"/>
</div>
</form>
<div class="clearfix"></div>
<?php if(isset($_REQUEST['view_attendance']))
{
$start_date = $_REQUEST['sdate'];
$end_date = $_REQUEST['edate'];
$user_id = $_REQUEST['user_id'];
$comment = $_REQUEST['comment'];
$attendance = smgt_view_student_attendance($start_date,$end_date,$user_id,$comment);
$curremt_date =$start_date;
?>
<div class="table-responsive">
<table class="table col-md-12">
<tr>
<th width="200px"><?php _e('Date','school-mgt');?></th>
<th><?php _e('Day','school-mgt');?></th>
<th><?php _e('Attendance','school-mgt');?></th>
<th><?php _e('Comment', 'school-mgt');?></th>
</tr>
<?php
while ($end_date >= $curremt_date)
{
echo '<tr>';
echo '<td>';
echo $curremt_date;
echo '</td>';
$attendance_status = smgt_get_attendence($user_id,$curremt_date);
echo '<td>';
echo date("D", strtotime($curremt_date));
echo '</td>';
if(!empty($attendance_status))
{
echo '<td>';
echo smgt_get_attendence($user_id,$curremt_date);
echo '</td>';
}
else
{
echo '<td>';
echo __('Absent','school-mgt');
echo '</td>';
}
echo '<td>';
echo $comment;
echo '</td>';
echo '</tr>';
$curremt_date = strtotime("+1 day", strtotime($curremt_date));
$curremt_date = date("Y-m-d", $curremt_date);
}
?>
</table>
</div>
<?php }?>
</div>
</div>
</div>
<?php
}
else
{?>
<div class="panel-body panel-white">
<ul class="nav nav-tabs panel_tabs" role="tablist">
<li class="active">
<a href="#child" role="tab" data-toggle="tab">
<i class="fa fa-align-justify"></i> <?php _e('Child List', 'school-mgt'); ?></a>
</a>
</li>
</ul>
<div class="tab-content">
<div class="panel-body">
<form name="wcwm_report" action="" method="post">
<div class="table-responsive">
<table id="student_list" class="display dataTable" cellspacing="0" width="100%">
<thead>
<tr>
<th width="75px"><?php _e( 'Photo', 'school-mgt' ) ;?></th>
<th><?php echo _e( 'Child Name', 'school-mgt' ) ;?></th>
<th><?php _e('Roll No.','school-mgt');?></th>
<th> <?php echo _e( 'Class', 'school-mgt' ) ;?></th>
<th> <?php echo _e( 'Child Email', 'school-mgt' ) ;?></th>
<th><?php echo _e( 'Action', 'school-mgt' ) ;?></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo _e( 'Photo', 'school-mgt' ) ;?></th>
<th><?php echo _e( 'Child Name', 'school-mgt' ) ;?></th>
<th><?php _e('Roll No.','school-mgt');?></th>
<th> <?php echo _e( 'Class', 'school-mgt' ) ;?></th>
<th> <?php echo _e( 'Child Email', 'school-mgt' ) ;?></th>
<th><?php echo _e( 'Action', 'school-mgt' ) ;?></th>
</tr>
</tfoot>
<tbody>
<?php
if(!empty($school_obj->child_list))
{
foreach ($school_obj->child_list as $child_id){
$retrieved_data= get_userdata($child_id);
if($retrieved_data)
{
?>
<tr>
<td class="user_image text-center"><?php $uid=$retrieved_data->ID;
$umetadata=get_user_image($uid);
if(empty($umetadata['meta_value']))
//echo get_avatar($retrieved_data->ID,'46');
echo '<img src='.get_option( 'smgt_student_thumb' ).' height="50px" width="50px" class="img-circle" />';
else
echo '<img src='.$umetadata['meta_value'].' height="50px" width="50px" class="img-circle"/>';
?></td>
<td class="name"><?php echo $retrieved_data->display_name;?></td>
<td><?php echo get_user_meta($retrieved_data->ID, 'roll_id',true);?></td>
<td class="name"><?php $class_id=get_user_meta($retrieved_data->ID, 'class_name',true);
echo $classname= get_class_name($class_id);
?></td>
<td class="email"><?php echo $retrieved_data->user_email;?></td>
<td class="action">
<a href="?dashboard=user&page=student&action=result&student_id=<?php echo $retrieved_data->ID;?>" class="show-popup btn btn-default"
idtest="<?php echo $retrieved_data->ID; ?>"><i class="fa fa-bar-chart"></i> <?php _e('View Result','school-mgt');?></a>
<a href="?dashboard=user&page=student&tab=studentlist&action=showparent&student_id=<?php echo $retrieved_data->ID;?>" class="show-parent btn btn-default"
idtest="<?php echo $retrieved_data->ID; ?>"><i class="fa fa-user"></i><?php _e('View Parent','school-mgt');?> </a>
<a href="?dashboard=user&page=child&student_id=<?php echo $retrieved_data->ID;?>&attendance=1" class="btn btn-default"
idtest="<?php echo $retrieved_data->ID; ?>"><i class="fa fa-eye"></i> <?php _e('View Attendance','school-mgt');?> </a>
</td>
</tr>
<?php }
}
}
?>
</tbody>
</table>
</div>
</form>
</div>
</div>
</div>
<?php
}
?>
Related
I'm currently working on the forum section of my website.
I followed the link #CBroe suggest me on the comments and implemented offcanvas for my previous problem and now I have this:
<table class="table is-indent changes" id="newsTable">
<thead>
<th></th>
<th></th>
</thead>
<tbody>
<?php foreach($fetchNews as $data):
echo '<tr class="trNew btnSelect" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasRight" aria-controls="offcanvasRight" id=\''.$data['id'].'\'>' ?>
<td class="cell-60 responsive-hide" style="width: 100px;">
<img class="author width" src="<?php echo '../../resource/img/users_Initials/' . $data['autore'].'.png' ?>">
</td>
<td id="<?php echo $data['id']; ?>">
<input type="hidden" id="idNew" value="<?php echo $data['id']; ?>" data-value="<?php echo $data['id']; ?>">
<div class="content">
<div class="title" id="title"> <?php echo $data['titolo']; ?> </div>
<div class="metas">
<span class="author"><?php echo $data['autore']; ?> - </span>
<span class="data"><?php echo $data['data']; ?></span>
</div>
</div>
<?php endforeach;?>
</td>
</tr>
</tbody>
</table>
And this is the offcanvas the table below open:
<!--PANEL NEWS-->
<?php foreach($fetchNews as $data):?>
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasRight" aria-labelledby="offcanvasRightLabel">
<div class="offcanvas-header">
<h1 id="newsTitolo"><?php echo $data['titolo']??''; ?></h1>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<div class="forum-header">
<img class="author width" src="<?php echo '../../resource/img/users_Initials/' . $data['autore'].'.png' ?>">
<span class="name"><?php echo $data['autore']??''; ?></span>
<span class="time"><?php echo $data['data']??''; ?></span>
</div>
<div class="forum-content">
<div id="newsTesto" class="articolo">
<?php $Parsedown = new Parsedown();
echo $Parsedown->text(file_get_contents('post/'.$data['titolo'].'/'.$data['titolo'].'.txt')??''); ?>
</div>
<p> <?php echo $data['allegato']??'';?></p>
</div>
</div>
</div>
<?php endforeach;?>
<!--END PANEL NEWS-->
What I basically need to do is display the article with the same ID as the title on the table as this example image: table & panel that by clicking on the first title (ahaaa) it opens the corresponding article.
I tried some stuff like adding $data['id'] on both data-bs-target and data-bs-toggle of the and as id of the offcanvas but it didnt work
I have JQUERY datatable in my PHP page in which I have one check box, I want to get the values of all the check boxes checked in that datatable with php code by using
implode(',',$_POST['accessflag']);
But it is showing the values only on the current page. I want to get the values of all checked check boxes in the datatable from all the pages of that particular table .anybody please help me to get this done.
my HTML code is
<div class="row control-container pt-2">
<div class="table-responsive col-md-12">
<div class="row">
<div class="col-md-12" style="text-align:center">
<label style="color:red">
<?php if (isset($_SESSION['SaveMsg'])) { echo $_SESSION['$SaveMsg'];unset($_SESSION['$SaveMsg']);}?>
</label>
</div>
</div>
<table id="moduletable" class="table table-sm table-bordered table-hover table-lightfont display">
<thead class="thead-light">
<tr>
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","GRP_DESC"); ?></th>
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MODULE_NAME"); ?></th>
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","GMA_ACCESS_FLAG"); ?></th>
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","OPTIONS"); ?></th>
</tr>
</thead>
<tbody>
<?php
if(isset($_SESSION['$nextset'])){
$limit=$_SESSION['$nextset'];}
else{$limit=0;}
if ($_SESSION['$language']="E") {
$groupdata=SelectData("group_module_access,user_group,modules","gma_id,gma_grp_id,grp_desc,gma_module_id,module_name,gma_access_flag","gma_grp_id=grp_id and gma_module_id=module_id","gma_grp_id,gma_id LIMIT ".$limit.",50");
}
else {
$groupdata=SelectData("group_module_access,user_group,modules","gma_id,gma_grp_id,grp_bldesc as grp_desc,gma_module_id,module_blname as module_name,gma_access_flag","gma_grp_id=grp_id and gma_module_id=module_id","gma_grp_id,gma_id LIMIT ".$limit.",50");
}
foreach ($groupdata as $groupdatalist) {?>
<tr>
<td><?php echo $groupdatalist["grp_desc"];?></td>
<td><?php echo $groupdatalist["module_name"];?></td>
<?php if($groupdatalist["gma_access_flag"]=="N"):?>
<td style="text-align:right;width:10px;"><input type="checkbox" name="accessflag[]" id="accessflag"
value="<?php echo "{$groupdatalist['gma_id']}"?>"/> </td>
<?php else:?>
<td style="text-align:right;width:10px;"><input type="checkbox" checked name="accessflag[]" id="accessflag" width="10px"
value="<?php echo "{$groupdatalist['gma_id']}"?>"/> </td>
<?php endif;?>
<!--<td style="display:none;"><//?php echo $groupdatalist["gma_grp_id"];?></td>
<td style="display:none;"><//?php echo $groupdatalist["gma_module_id"];?></td>
<td style="display:none;"><input type="text" name="gmaid" id="gmaid" value="<//?php echo $groupdatalist["gma_id"];?>"></td>-->
<td>
<?php if($groupdatalist["gma_access_flag"]=="N"):?>
<a href="#" class="btn btn-light btn-sm pt-0 shadow-none"
data-toggle="tooltip" title="<?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MENUPERMISSION");?>">
<i class="fa fa-pencil-square-o"></i>
</a>
<?php else:?>
<a href="group_action.php?gmagrpid=<?php echo $groupdatalist['gma_grp_id']?>&gmamoduleid=<?php echo $groupdatalist['gma_module_id']?>&page=MenuPermission&gmagrpdesc=<?php echo $groupdatalist['grp_desc']?>&gmamodulename=<?php echo $groupdatalist['module_name']?>" class="btn btn-light btn-sm pt-0 shadow-none"
data-toggle="tooltip" title="<?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MENUPERMISSION");?>">
<i class="fa fa-pencil-square-o"></i>
</a>
<?php endif;?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<div class="row">
<div class="col-md-12 text-right">
<button type="submit" name="updmodaccess" formnovalidate class="btn nc btn-primary btn-rounded">
<i class="fa fa-save"></i>
<?php echo GetBilingualLabels($_SESSION['$language'],"BUTTON","SAVE"); ?>
</button>
</div>
</div>
</div>
</div>
PHP code on updmodaccess button is
if (isset($_POST['updmodaccess'])) {
$keytoupdate=implode(',',$_POST['accessflag']);
$table="group_module_access"; $data=array("gma_access_flag"=>"Y", "gma_upd_dt"=>GetDateTime($_SESSION['$TimeZone']), "gma_upd_uid"=>"{$_SESSION['$userid']}");
UpdateData($table,$data,"gma_id in (".$keytoupdate.")",$Message,$flg);
$data=array("gma_access_flag"=>"N", "gma_upd_dt"=>GetDateTime($_SESSION['$TimeZone']), "gma_upd_uid"=>"{$_SESSION['$userid']}");
UpdateData($table,$data,"gma_id not in (".$keytoupdate.")",$Message,$flag);
}
you can try the following code. I hope it helps.
you need to get these values using ajax and then need to send this value to php using an ajax.
$(document).ready(function(){
var data = new Object();
var table = $('#addUsersToAboTable').DataTable();
$('#addUsersToAboTable').on('change', ':checkbox', function () {
data[table.row($(this).parents('tr').get(0)).index()] = this.checked;
});
$('#getDataBtn').on('click',function(){
console.log(data);
});
});
Here you can see the demo script as well jQuery Datatables, How to get all selected checkboxes from EVERY page
I am using CodeIgniter 2.2.
I have to update database with +1 every time a page is visited. Code works but it get incremented by +2 every time.
Example: if total views=2, once the page is clicked total views should be 3, but the value in the database is 4.
I am sure that I am calling the model add_one_to_view_image only once in my controller.
controller
function view(){
$view_id = $this->uri->segment(3);
if($view_id){
$this->property->add_one_to_view_image($view_id);
$prop['prop_detail'] = $this->property->get_single_property_for_view($view_id);
$prop['prop_imgs'] = $this->property->get_single_property_images($view_id);
$prop['amenities'] = $this->property->get_single_property_amenities($view_id);
$prop['latest'] = $this->home->get_latest_properties();
$size = sizeof($prop['latest']);
for($k=0; $k< $size; $k++){
$Image_name = $this->property->get_property_first_image($prop['latest'][$k]->property_id);
if($Image_name){
$prop['latest'][$k]->image=$Image_name[0]->name;
}else {
$prop['latest'][$k]->image="";
}
}
$this->load->view('property_view', $prop);
}
}
Model
function add_one_to_view_image($id){
echo "We in add one to views";
$this->db->where('property_id', $id);
$this->db->set('views', 'views+1', FALSE);
$this->db->update('property_views');
}
I added a echo statement inside the model. and it prints only once..
View
<!DOCTYPE html>
<html lang="en-US">
<head>
<?php $this->load->view('header_links'); ?>
<title><?php echo $prop_detail[0]->title; ?> | lanka Property</title>
<meta name="author" content="Sathyabaman - lankaproperty.com">
<meta name="description" content="<?php echo $prop_detail[0]->full_description; ?>">
<meta name="keywords" content="home, land, apartment, house, room, Commercial Building, buy, sell, rent, lease, sri lanka">
</head>
<body>
<div id="wrapper-outer" >
<div id="wrapper">
<div id="wrapper-inner">
<?php $this->load->view('header_top_user_bar'); ?>
<?php $this->load->view('header_logo'); ?>
<?php $this->load->view('navigation'); ?>
<!-- CONTENT -->
<div id="content"><div class="container">
<div id="main">
<div class="row">
<div class="span9">
<h1 class="page-header"><?php echo $prop_detail[0]->title; ?></h1>
<div class="carousel property">
<div class="preview">
<li class="active">
<img src="<?php echo base_url(); ?>/upload_images/<?php echo $prop_imgs[0]->name; ?>" alt="">
</li>
</div><!-- /.preview -->
<div class="content">
<a class="carousel-prev" href="#">Previous</a>
<a class="carousel-next" href="#">Next</a>
<ul>
<?php foreach ($prop_imgs as $img) : ?>
<li class="active">
<img src="<?php echo base_url(); ?>/upload_images/<?php echo $img->name; ?>" alt="">
</li>
<?php endforeach; ?>
</ul>
</div>
<!-- /.content -->
</div>
<!-- /.carousel -->
<div class="property-detail">
<div class="pull-left overview">
<div class="row">
<div class="span3">
<h2>Overview</h2>
<?php foreach ($prop_detail as $dtl) : ?>
<table>
<tr>
<?php if($dtl->status == 0){?>
<td style="font-size: 120%;"><strong>Under Approval</strong></td>
<?php } if($dtl->status == 1){?>
<td style="color:green; font-size: 200%;"><strong>Available!</strong></td>
<?php } if($dtl->status == 2){?>
<td style="color:red; font-size: 200%;"><strong>Expired!</strong></td>
<?php } if($dtl->status == 3){?>
<td style="color:red; font-size: 200%;"><strong>Deleted!</strong></td>
<?php } if($dtl->status == 4){?>
<td style="color:red; font-size: 200%;"><strong>Suspended!</strong></td>
<?php } ?>
</tr>
<tr>
<th></th>
<td><br/></td>
</tr>
<tr>
<th>Property ID :</th>
<td> PPTID<?php echo $dtl->property_id; ?></td>
</tr>
<tr>
<th>Price :</th>
<td><?php if($dtl->price == 0){ echo "negotiable"; }
else {
$price_text = (string)$dtl->price; // convert into a string
$arr = str_split($price_text, "3"); // break string in 3 character sets
$price_new_text = implode(",", $arr); // implode array with comma
echo 'Rs. '.$price_new_text.'/=';
} ?>
</td>
</tr>
<tr>
<th>Property type :</th>
<td><?php echo $dtl->type_name; ?></td>
</tr>
<tr>
<th>Property size :</th>
<td><?php echo $dtl->size; ?> <?php echo $dtl->size_type; ?></td>
</tr>
<tr>
<th>Contract type :</th>
<td><?php echo $dtl->contract_type; ?></td>
</tr>
<?php if($dtl->bed){ ?>
<tr>
<th>Bedrooms :</th>
<td><?php echo $dtl->bed; ?></td>
</tr>
<?php } if($dtl->bath){ ?>
<tr>
<th>Bathrooms :</th>
<td><?php echo $dtl->bath; ?></td>
</tr>
<?php } if($dtl->address){?>
<tr>
<th>address :</th>
<td><?php echo $dtl->address; ?></td>
</tr>
<?php } ?>
<tr>
<th>Area :</th>
<td><?php echo $dtl->area; ?></td>
</tr>
<tr>
<th>City :</th>
<td><?php echo $dtl->city; ?></td>
</tr>
<?php if($dtl->Contact_name){ ?>
<tr>
<th>Contact Name :</th>
<td><?php echo $dtl->Contact_name; ?></td>
</tr>
<?php } ?>
<tr>
<th>Contact No 1 :</th>
<td><strong><?php echo chunk_split($dtl->phone_home, 3, ' '); ?></strong></td>
</tr>
<?php if($dtl->phone_hand){ ?>
<tr>
<th>Contact No 2 :</th>
<td><strong><?php echo chunk_split($dtl->phone_hand, 3, ' '); ?></strong></td>
</tr>
<?php } ?>
<tr><td colspan="2">
<br/>
<a class="btn btn-primary btn-large list-your-property">
Contact : <?php echo chunk_split($dtl->phone_home, 3, ' '); ?></a>
</td></tr>
</table>
</div>
<!-- /.span2 -->
</div>
<!-- /.row -->
</div>
<p><?php echo nl2br($dtl->full_description); ?>.</p>
<?php endforeach; ?>
<br/><br/>
<h2>General amenities</h2>
<div class="row">
<ul class="span2">
<li class="<?php if($amenities[0]->Gym==1){echo 'checked'; }else{echo 'plain';} ?>">
Gym
</li>
<li class="<?php if($amenities[0]->Air_conditioning==1){echo 'checked'; }else{echo 'plain';} ?>">
Air Conditioning
</li>
<li class="<?php if($amenities[0]->internet==1){echo 'checked'; }else{echo 'plain';} ?>">
Internet
</li>
<li class="<?php if($amenities[0]->Wifi==1){echo 'checked'; }else{echo 'plain';} ?>">
Wifi
</li>
<li class="<?php if($amenities[0]->Lift==1){echo 'checked'; }else{echo 'plain';} ?>">
Lift
</li>
<li class="<?php if($amenities[0]->Furnished==1){echo 'checked'; }else{echo 'plain';} ?>">
Furnished
</li>
</ul>
<ul class="span2">
<li class="<?php if($amenities[0]->Television==1){echo 'checked'; }else{echo 'plain';} ?>">
Television
</li>
<li class="<?php if($amenities[0]->Hot_Water==1){echo 'checked'; }else{echo 'plain';} ?>">
Hot Water
</li>
<li class="<?php if($amenities[0]->Smoking_allowed==1){echo 'checked'; }else{echo 'plain';} ?>">
Smoking Allowed
</li>
<li class="<?php if($amenities[0]->Pets_allowed==1){echo 'checked'; }else{echo 'plain';} ?>">
Pets Allowed
</li>
<li class="<?php if($amenities[0]->Garage==1){echo 'checked'; }else{echo 'plain';} ?>">
Garage
</li>
<li class="<?php if($amenities[0]->Secure_parking==1){echo 'checked'; }else{echo 'plain';} ?>">
Secure parking
</li>
</ul>
<ul class="span2">
<li class="<?php if($amenities[0]->Swimming_Pool==1){echo 'checked'; }else{echo 'plain';} ?>">
Swimming Pool
</li>
<li class="<?php if($amenities[0]->Tennis_court==1){echo 'checked'; }else{echo 'plain';} ?>">
Tennis court
</li>
<li class="<?php if($amenities[0]->Balcony==1){echo 'checked'; }else{echo 'plain';} ?>">
Balcony
</li>
<li class="<?php if($amenities[0]->Fenced==1){echo 'checked'; }else{echo 'plain';} ?>">
Fenced
</li>
<li class="<?php if($amenities[0]->Back_up_Generator==1){echo 'checked'; }else{echo 'plain';} ?>">
Back Up Generator
</li>
<li class="<?php if($amenities[0]->Garden==1){echo 'checked'; }else{echo 'plain';} ?>">
Garden
</li>
</ul>
<ul class="span2">
<li class="<?php if($amenities[0]->Waterfront==1){echo 'checked'; }else{echo 'plain';} ?>">
Waterfront
</li>
<li class="<?php if($amenities[0]->Ocean_View==1){echo 'checked'; }else{echo 'plain';} ?>">
Ocean View
</li>
<li class="<?php if($amenities[0]->Security==1){echo 'checked'; }else{echo 'plain';} ?>">
Security
</li>
<li class="<?php if($amenities[0]->Water_Tank==1){echo 'checked'; }else{echo 'plain';} ?>">
Water Tank
</li>
</ul>
</div>
<!--
<h2>Map</h2>
<div id="property-map"></div> -->
</div>
</div>
<div class="sidebar span3">
<div class="widget contact">
<div class="title">
<h2 class="block-title">Contact Owner</h2>
</div><!-- /.title -->
<div class="content">
<form method="post" id="frm_contact_owner">
<div class="alert alert-success" id="co_sucess_message" style="display: none">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Message successfully send to owner!. <br/>Thank you!</strong>
</div>
<input type="hidden" name="co_property_id" value="<?php echo $dtl->property_id; ?>">
<div class="control-group">
<label class="control-label" >
Name
<span class="form-required" title="This field is required.">*</span>
<span class="form-required" id="co_name_error" title="This field is required."></span>
</label>
<div class="controls">
<input type="text" name="co_name" id="co_name">
</div><!-- /.controls -->
</div><!-- /.control-group -->
<div class="control-group">
<label class="control-label" >
Email
<span class="form-required" title="This field is required.">*</span>
<span class="form-required" id="co_email_error" title="This field is required."></span>
</label>
<div class="controls">
<input type="text" name="co_email" id="co_email">
</div><!-- /.controls -->
</div><!-- /.control-group -->
<div class="control-group">
<label class="control-label" >
Message
<span class="form-required" title="This field is required.">*</span>
<span class="form-required" id="co_message_error" title="This field is required."></span>
</label>
<div class="controls">
<textarea name="co_message" id="co_message"></textarea>
</div><!-- /.controls -->
</div><!-- /.control-group -->
<div class="form-actions">
<input type="submit" id="co_send" class="btn btn-primary arrow-right" value="Send">
<img id="co_ajax_image" src="<?php echo base_url(); ?>html/assets/img/ajax_loader.gif" alt="" style="float: left; display:none">
</div><!-- /.form-actions -->
</form>
</div><!-- /.content -->
</div><!-- /.widget -->
<div class="widget properties last">
<div class="title">
<h2>Latest Properties</h2>
</div><!-- /.title -->
<div class="content">
<?php foreach ($latest as $latest_pro) :?>
<div class="property">
<div class="image">
<?php
if($latest_pro->image){
$image_name = base_url().'upload_images/'.$latest_pro->image;
}else{
$image_name = base_url().'html/assets/img/tmp/property-small-5.png';
}
?>
<img src="<?php echo $image_name; ?>" alt="">
</div><!-- /.image -->
<div class="wrapper">
<div class="title">
<h3>
<?php echo substr($latest_pro->title, 0, 16); ?>..
</h3>
</div><!-- /.title -->
<div class="location"><?php echo $latest_pro->area; ?>, <?php echo $latest_pro->city; ?></div><!-- /.location -->
<div class="price">
<?php if($latest_pro->price == 0){ echo "negotiable"; }
else {
$price_text = (string)$latest_pro->price; // convert into a string
$arr = str_split($price_text, "3"); // break string in 3 character sets
$price_new_text = implode(",", $arr); // implode array with comma
echo 'Rs. '.$price_new_text.'/=';
} ?>
</div><!-- /.price -->
</div><!-- /.wrapper -->
</div><!-- /.property -->
<?php endforeach; ?>
</div><!-- /.content -->
</div><!-- /.properties -->
</div>
</div>
</div>
</div>
</div><!-- /#content -->
</div><!-- /#wrapper-inner -->
<?php $this->load->view('footer'); ?>
</div><!-- /#wrapper -->
</div><!-- /#wrapper-outer -->
<?php $this->load->view('footer_setting_palette'); ?>
<?php //$this->load->view('property_filter_ajax'); ?>
<?php $this->load->view('say_hello_ajax'); ?>
<?php $this->load->view('property_contact_owner'); ?>
</body>
</html>
I know it's completly illlogical but check this out....
I had also got the same issue long back but after 1 week of headache I come to know about this solution.
I got the solution from this link, check out the 2nd answer. Initially I also didn't take that solution seriously but in the end it worked for me :)
Solution :
Make sure you don't have tag with empty src="" attribute or any css style refering to empty url (like background: url();) on your site around the place when you have your code that runs twice.
try this solution, i have also done this same in my project and didn't face any problem. if i see logically there is no problem with your code but just try row() instead of result() function and than see if it have the same impact. and make sure default value of the column view is 0
function add_one_to_view_image($id){
$this->db->select('views');
$this->db->from('property_views');
$this->db->where('property_id', $id);
$pag = $this->db->get();
$resultset = $pag->row();
$newvalue = ++$resultset->views;
$data = array('views' => $newvalue);
$this->db->where('property_id', $id);
$this->db->update('property_views', $data);
}
when you are going to get 1 row is bettery to get it by row rather than getting it as a result.
Regards
You can make the incrementation directly in active record :
Refering to the documentation :
set() will also accept an optional third parameter ($escape), that
will prevent data from being escaped if set to FALSE.
So the views+1will not be escaped and the query will work correctly :
function add_one_to_view_image($id){
$this->db->where('property_id', $id);
$this->db->set('views', 'views+1', FALSE);
$this->db->update('property_views');
}
Check your webserver access log. My guess is that you're calling your page twice... Either from a bad link (empty src), redirect to it on a 404 (missing favicon?) or something similar.
I've got the same problem when i'm making a view counter it's getting incremented multiple times.
then i came up with the solution to use $this->db->cache_delete_all();
function add_one_to_view_image($id){
$this->db->cache_delete_all();
$this->db->where('property_id', $id);
$this->db->set('views', 'views+1', FALSE);
$this->db->update('property_views');
}
But in my senario i was using direct query eg:
$this->db->query("Update settings set option_value = '{$newCounter}' where option_name = 'counter'");
Hope it will fix your problem.
I want to change the color of the div of this table (all records that status = no in the database ),Which means unread message should have a different div class. I have no idea how to do this i am using codeigniter as my framework
My view
<div class="row">
<div class="span10 box" style="padding: 10px;">
<?php echo form_open('admin/messages'); ?><!-- start of the form -->
<p>Recent Messages</p>
<table class="table hovered">
<thead>
<tr class="selected">
<th class="text-left">Name</th>
<th class="text-left">Email</th>
<th class="text-left">Phone</th>
<th class="text-left">Message</th>
</tr>
</thead>
<tbody>
<?php
if(isset($records)) :
foreach($records as $row) :
?>
<tr>
<td class="right"><?php echo $row->contactus_name; ?></td>
<td class="right"><?php echo $row->contactus_email; ?></td>
<td class="right"><?php echo $row->contactus_phone; ?></td>
<td class="right tertiary-text-secondary text-justify"><?php echo $row->contactus_comment; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot></tfoot>
</table>
<?php else : ?>
<p>No records</p>
<?php endif; ?>
</div>
<div class="span3">
<nav class="sidebar dark">
<ul>
<li>
<a href="#">
<i class="icon-home"></i>
Inbox <strong>
<?php if(isset($count)){echo '<div class="brand"><div class="badge bg-red">'.$count.'</div></div>';}?>
</strong>
</a>
</li>
<li>
<a href="#">
<i class="icon-home"></i>
Send
</a>
</li>
<li>
<a href="#">
<i class="icon-home"></i>
Newsletter/Ad
</a>
</li>
</ul>
</nav>
</div>
<?php echo form_close(); ?><!-- END of the form -->
</div>
Providing a link to / your code would allow us to give far more specific advice, but in general:
<?php if ($foo == 'bar') { $class_name = 'class1'; } else { $class_name = 'class2'; } ?>
<div class="<?php echo $class_name; ?>">
foreach($results as $row)
{
echo '<div '. ($row->read == 0 ? ' class="unread"': '') .'>Your content</div>';
}
This question already has answers here:
codeigniter upload file error
(2 answers)
Closed 8 years ago.
I want to upload a file in mysql database using php codeigniter. when I upload a file it don't show any error and file doesn't upload.and the value of column file_name in mysql shows as NULL.
Here is my view code :
<div class="box">
<div class="box-header"><span class="title"><?php echo get_phrase('diagnosis_report');?></span></div>
<div class="box-content">
<table cellpadding="0" cellspacing="0" border="0" class="table table-normal ">
<thead>
<tr>
<td><div>#</div></th>
<td><div><?php echo get_phrase('report_type');?></div></td>
<td><div><?php echo get_phrase('document_type');?></div></td>
<td><div><?php echo get_phrase('download');?></div></td>
<td><div><?php echo get_phrase('description');?></div></td>
<td><div><?php echo get_phrase('date');?></div></td>
<td><div><?php echo get_phrase('laboratorist');?></div></td>
<td><div><?php echo get_phrase('option');?></div></td>
</tr>
</thead>
<tbody>
<?php
$count = 1;
$diagnostic_reports = $this->db->get_where('diagnosis_report' , array('prescription_id' => $prescription_id))->result_array();
foreach($diagnostic_reports as $row2):?>
<tr>
<td><?php echo $count++;?></td>
<td><?php echo $row2['report_type'];?></td>
<td><?php echo $row2['document_type'];?></td>
<td style="text-align:center;">
<?php if($row2['document_type'] == 'image'):?>
<div id="thumbs">
<a href="<?php echo base_url();?>uploads/diagnosis_report/<?php echo $row2['file_name'];?>"
style="background-image:url(<?php echo base_url();?>uploads/diagnosis_report/<?php echo $row2['file_name'];?>)" title="<?php echo $row2['file_name'];?>">
</a></div>
<?php endif;?>
<a href="<?php echo base_url();?>uploads/diagnosis_report/<?php echo $row2['file_name'];?>" target="_blank"
class="btn btn-blue"> <i class="icon-download-alt"></i> <?php echo get_phrase('download');?></a>
</td>
<td><?php echo $row2['description'];?></td>
<td><?php echo date('d M,Y', $row2['timestamp']);?></td>
<td><?php echo $this->crud_model->get_type_name_by_id('laboratorist',$row2['laboratorist_id'],'name');?></td>
<td align="center">
<a href="<?php echo base_url();?>index.php?laboratorist/manage_prescription/delete_diagnosis_report/<?php echo $row2['diagnosis_report_id'];?>/<?php echo $prescription_id;?>" onclick="return confirm('delete?')"
rel="tooltip" data-placement="top" data-original-title="<?php echo get_phrase('delete');?>" class="btn btn-red">
<i class="icon-trash"></i>
</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
</div>
<!------DIAGNOSTIC REPORT FOR THIS PRESCRIPTION---->
<!------ADD A DIAGNOSTIC REPORT TO THIS PRESCRIPTION-->
<div class="box">
<div class="box-header"><span class="title"><?php echo get_phrase('add_diagnosis_report');?></span></div>
<div class="box-content">
<?php echo form_open('laboratorist/manage_prescription/create_diagnosis_report' , array('class' => 'form-horizontal validatable'));?>
<div class="padded">
<div class="control-group">
<label class="control-label"><?php echo get_phrase('report_type');?></label>
<div class="controls">
<input type="text" name="report_type" /> <span class="label label-blue">report type can be x-ray, blood-test etc.</span>
</div>
</div>
<div class="control-group">
<label class="control-label"><?php echo get_phrase('document_type');?></label>
<div class="controls">
<select name="document_type" >
<option value="image"><?php echo get_phrase('image');?></option>
<option value="doc" ><?php echo get_phrase('doc');?></option>
<option value="pdf"><?php echo get_phrase('pdf');?></option>
<option value="excel"><?php echo get_phrase('excel');?></option>
<option value="other"><?php echo get_phrase('other');?></option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label"><?php echo get_phrase('upload_document');?></label>
<div class="controls">
<input type="file" name="userfile" />
</div>
</div>
<div class="control-group">
<label class="control-label"><?php echo get_phrase('description');?></label>
<div class="controls">
<textarea name="description" ></textarea>
</div>
</div>
<div class="control-group">
<div class="controls">
<input type="hidden" name="prescription_id" value="<?php echo $prescription_id;?>" />
<button type="submit" class="btn btn-blue"><?php echo get_phrase('add_diagnosis_report');?></button>
</div>
</div>
</div>
</form>
</div>
</div>
and here is my code to upload file in database :
function manage_prescription($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('laboratorist_login') != 1)
redirect(base_url() . 'index.php?login', 'refresh');
if ($param1 == 'create_diagnosis_report') {
$data['report_type'] = $this->input->post('report_type');
$data['document_type'] = $this->input->post('document_type');
$data['prescription_id'] = $this->input->post('prescription_id');
$data['description'] = $this->input->post('description');
$data['timestamp'] = strtotime(date('Y-m-d') . ' ' . date('H:i:s'));
$data['laboratorist_id'] = $this->session->userdata('laboratorist_id');
move_uploaded_file($_FILES["userfile"]["tmp_name"] , "uploads/diagnosis_report/".$_FILES["userfile"]["name"]);
$data['file_name'] = $_FILES["userfile"]["name"];
$this->db->insert('diagnosis_report', $data);
$this->session->set_flashdata('flash_message', get_phrase('diagnosis_report_created'));
redirect(base_url() . 'index.php?laboratorist/manage_prescription/edit/' . $this->input->post('prescription_id'), 'refresh');
}
if ($param1 == 'delete_diagnosis_report') {
$this->db->where('diagnosis_report_id', $param2);
$this->db->delete('diagnosis_report');
$this->session->set_flashdata('flash_message', get_phrase('diagnosis_report_deleted'));
redirect(base_url() . 'index.php?laboratorist/manage_prescription/edit/' . $param3, 'refresh');
} else if ($param1 == 'edit') {
$page_data['edit_profile'] = $this->db->get_where('prescription', array(
'prescription_id' => $param2
))->result_array();
}
$page_data['page_name'] = 'manage_prescription';
$page_data['page_title'] = get_phrase('manage_prescription');
$page_data['prescriptions'] = $this->db->get('prescription')->result_array();
$this->load->view('index', $page_data);
}
You have to use form_open_multipart() not form_open() in your view file