codeigniter flash message not working - php

I could not display flash message in my project (view file), any body help I kill my several time to display $flash message in my view page. I am new in counterfeiter, trying to learn something from online.
Controller :
function delete_image($update_id)
{
if(!is_numeric($update_id))
{
redirect('site_security/not_allowed');
}
$this->load->library('session');
$this->load->module('site_security');
$this->site_security->_make_sure_is_admin();
$data = $this->fetch_data_from_db($update_id);
$picture = $data['picture'];
$big_pic_path = './media/blog_pics/'.$picture;
$small_picture = str_replace('.', '_thumb.', $picture);
$small_pic_path = './media/blog_pics/'.$small_picture;
//attempt to remove the images
if (file_exists($big_pic_path)) {
unlink($big_pic_path);
}
if (file_exists($small_pic_path)) {
unlink($small_pic_path);
}
//update the database
unset($data);
$data['picture'] = "";
$this->_update($update_id, $data);
$flash_msg = "The image was successfully deleted.";
$value = '<div class="alert alert-success" role="alert">'.$flash_msg.'</div>';
$this->session->set_flashdata('item', $value);
redirect('blog/create/'.$update_id);
}
View File :
<h1><?= $headline ?></h1>
<?= validation_errors("<p style='color: red;'>", "</p>") ?>
<?php
if(isset($flash)){
echo $flash;
}
?>
<?php
if(is_numeric($update_id)) { ?>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header" data-original-title>
<h2><i class="halflings-icon white edit"></i><span class="break"></span>Additional Option</h2>
<div class="box-icon">
<i class="halflings-icon white chevron-up"></i>
<i class="halflings-icon white remove"></i>
</div>
</div>
<div class="box-content">
<?php
if($picture==""){
?>
<button type="button" class="btn btn-primary">Upload Image</button>
<?php
}
else
{
?>
<button type="button" class="btn btn-danger">Delete Image</button>
<?php
}
if($update_id>2){
?>
<button type="button" class="btn btn-danger">Delete Blog Entry</button>
<?php
}
?>
<button type="button" class="btn btn-default">View Blog Entry</button>
</div>
</div><!--/span-->
</div><!--/row-->
<?php
}
?>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header" data-original-title>
<h2><i class="halflings-icon white edit"></i><span class="break"></span>Blog Entry Details</h2>
<div class="box-icon">
<i class="halflings-icon white chevron-up"></i>
<i class="halflings-icon white remove"></i>
</div>
</div>
<div class="box-content">
<?php
$form_location = base_url()."blog/create/".$update_id;
?>
<form class="form-horizontal" method="post" action="<?= $form_location ?>">
<fieldset>
<div class="control-group">
<label class="control-label" for="typeahead">Date Published </label>
<div class="controls">
<input type="text" name="date_published" class="input-xlarge datepicker" id="date01" value="<?= $date_published ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="typeahead">Blog Entry Title </label>
<div class="controls">
<input type="text" class="span7" name="page_title" value="<?= $page_title ?>">
</div>
</div>
<div class="control-group hidden-phone">
<label class="control-label">Blog Entry Keywords</label>
<div class="controls">
<textarea class="span7" rows="3" name="page_keywords"><?php echo $page_keywords; ?> </textarea>
</div>
</div>
<div class="control-group hidden-phone">
<label class="control-label">Blog Entry Description</label>
<div class="controls">
<textarea class="span7" rows="3" name="page_description"><?php echo $page_description; ?> </textarea>
</div>
</div>
<div class="control-group hidden-phone">
<label class="control-label" for="textarea2">Blog Entry Content</label>
<div class="controls">
<textarea class="cleditor" id="textarea2" rows="3" name="page_content"><?php echo $page_content; ?> </textarea>
</div>
</div>
<div class="control-group">
<label class="control-label" for="typeahead">Author </label>
<div class="controls">
<input type="text" class="span7" name="author" value="<?= $author ?>">
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary" name="submit" value="Submit">Submit</button>
<button type="submit" name="submit" value="Cancel" class="btn">Cancel</button>
</div>
</fieldset>
</form>
</div>
</div><!--/span-->
</div><!--/row-->
<?php
if(isset($picture) && ($picture!=null) ){
?>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header" data-original-title>
<h2><i class="halflings-icon white edit"></i><span class="break"></span>Image</h2>
<div class="box-icon">
<i class="halflings-icon white chevron-up"></i>
<i class="halflings-icon white remove"></i>
</div>
</div>
<div class="box-content">
<img src="<?= base_url() ?>media/blog_pics/<?= $picture ?>" class="thumbnail" width="100">
</div>
</div><!--/span-->
</div><!--/row-->
<?php
}
?>

If you want to get the flashdata message you have set
Try
<?php if($this->session->flashdata('item')) {?>
<?php echo $this->session->flashdata('item');?>
<?php }?>

Your just change this code
<?php
if(isset($flash)){
echo $flash;
}
?>
To
<?php
if(isset($this->session->flashdata('item'))){
echo $flash;
}
?>

In your controller change
$flash_msg = "The image was successfully deleted.";
$value = '<div class="alert alert-success" role="alert">'.$flash_msg.'</div>';
$this->session->set_flashdata('item', $value);
To
$this->session->set_flashdata('item', 'The image was successfully deleted.');
In your view page add
<?php if($this->session->flashdata('item')){ ?>
<div class="alert alert-success">
<h4><?php echo $this->session->flashdata('item'); ?></h4>
</div>
<?php } ?>

Related

i am using ajax my with pagination on next page no. 2 my 'Edit' button and 'validation' not working

this picture is pagination and inspect values on edit button : enter image description here
my problem is that unable to edit value on next page in ajax, on first page edit button working,
and successfully edit validation not working after edit value.
on edit button values coming in json format i have only some knowledge of json and ajax
My database table:
-----------------------------------
sport_id | sport_name
-------------------------------------
1 | Volleyball
2 | Basketball
----------------------------------
table name is:- sports
my code is like that
controller
===========
public function add_sport() {
unset($_POST['gym_account_id']);
if(isset($_POST['sport_id'])){
unset($_POST['sport_id']);
$response = $this->queryData->sportAddData($_POST);
}else{
$sport_id = $_POST['sport_id'];
// alert($sport_id);
$sport_name = array("sport_name" => $_POST['sport_name']);
$response = $this->queryData->sportEditData($sport_name,$sport_id);
}
$this->Sports();
}
model
========
public function sportAddData($data) {
$this->db->insert('sports', $data);
$insert_id = $this->db->insert_id();
return $insert_id;
}
public function sportEditData($sport_name,$sport_id) {
$this->db->where('sport_id', $sport_id);
$this->db->update('sports', $sport_name);
}
view
======
<div class="page-title">
<div class="title_left">
<div class="alert alert-success alert-dismissible fade in" role="alert" style="display: <?php echo (!empty($_GET['success'])) ? 'block' : 'none'; ?>">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
</button>
<strong>Success!</strong> <?php echo $_GET['success']; ?>
</div>
</div>
<div class="title_right">
<div class="col-md-12 col-sm-5 col-xs-12 form-group pull-right top_search" style="text-align: right; margin-bottom: 26px; margin-right: -4px;">
<button type="button" class="btn btn-dark create_sport1">Create</button>
<button type="button" class="btn btn-dark delete_items" >Delete</button>
<button type="button" class="btn btn-dark call_delete" data-toggle="modal" data-target=".bs-example-modal-sm" style="display: none;" >Delete Athlete</button>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="row sport_form_block" id="add_sports" style="display: none;">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2 class="form_title1">Create New Sport</h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
<br />
<form id="demo-form2" method="POST" data-parsley-validate class="form-horizontal form-label-left sport_form">
<?php
$userType = $this->session->userData('userType');
$gymAccountId = $this->session->userData('gym_account_id');
if($userType == 1){
?>
<?php }else{ ?>
<input type="hidden" name="gym_account_id" id="gym_account_id" value="<?php echo $gymAccountId; ?>" />
<?php } ?>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="sport_name">Sport Name <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="sport_name" name="sport_name" required="required" class="form-control col-md-7 col-xs-12 edit_sportname">
</div>
</div>
<div class="ln_solid"></div>
<div class="form-group">
<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
<input type="hidden" name="sport_id" value="" class="editsportid" id="editsportid" />
<button class="btn btn-primary close_form" data-div="sport_form_block" type="button">Cancel</button>
<button class="btn btn-primary reset_sport_form" type="reset">Reset</button>
<!-- <button type="button" class="btn btn-success submit_athlete1" data-url="<php echo base_url(); ?>athlete/add_athlete" data-table="<php echo base_url(); ?>athlete/get_athlete" data-form="athlete_form" data-div="athlete_form_block">Submit</button>-->
<button type="submit" class="btn btn-success submit_athlete1" data-url="<?php echo base_url(); ?>Index/add_sport" data-table="<?php echo base_url(); ?>sport/get_athlete" data-form="sport_form" data-div="sport_form_block">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>Sport(s)<small></small></h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
<table id="sport-athlete-datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap bulk_action" cellspacing="0" width="100%">
<thead>
<tr>
<th class="no-sort" style="width: 30px;" ><input type="checkbox" id="check-all" class="flat check_all" data-check="athlete_list"></th>
<th>Id</th>
<th>Sport</th>
<th class="no-sort" style="width: 50px;" >Edit</th>
</tr>
</thead>
<tbody>
<?php foreach ($data['athletes'] as $key => $value) { ?>
<tr>
<!-- <td><input type="checkbox" id="<php echo $value['athlete_id']; ?>" class="flat athlete_list multiple_delete"></td>-->
<td><input type="checkbox" id="<?php echo $value['sport_id']; ?>" class="flat athlete_list multiple_delete"></td>
<td><?php echo $value['sport_id']; ?></td>
<td><?php echo $value['sport_name']; ?></td>
<!--<td></i></td>-->
<td><button class="edit_sport option_icon" data-json='<?php echo $value['sport_id'] . ',' . $value['sport_name'] ?>' data-block="sport_form_block" data-form="sport_form" ><i class="fa fa-edit"></i></button></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
js
==
$('.edit_sport').on('click', function (e) {
//$('.edit_sport').on('click', function (e) {
$('#add_sports').slideDown();
id = $(this).attr("data-json");
var arr = id.split(',');
$('.edit_sportname').val(arr[1]);
$('.editsportid').val(arr[0]);
alert(arr);
console.log(arr);
$('#function').val("update");
$('.form_title1').html('Edit Sports');
$('.' + $(this).data("block")).show();
$("html, body").animate({scrollTop: 0}, "slow");
});
Because you use onclick to bind event on button which will not apply for new element add to DOM via ajax call. You can use delegate or on to attach an events.

Text from database overflow bootstrap container

I'm trying to get a text from the database but it overflows it's container. I tried putting a lot of lorem ipsum in the original code without the database info and it works fine.
This is what happen when I get the info directly from the database:
And this is a native lorem ipsum in the html file:
This is my html code:
<div class="col-md-8">
<div class="row">
<?php
$query = $mysqli->query("SELECT id,title,preview,author,timepost FROM news ORDER BY timepost DESC LIMIT 3");
$i = 1;
while($array = $query->fetch_array())
{
$date = DateTime::createFromFormat("Y-m-d H:i:s",$array['timepost']); ?>
<div class="col-md-12 mb-3" style="cursor: default;" id="<?php echo 'newsJunebia' . $i; $i++; ?>">
<div class="row">
<div class="col-md-12 bg-negro text-white rounded-top">
<strong><?= $array['title']; ?></strong>
</div>
</div>
<div class="row">
<div class="col-md-8 bg-negro-opacity text-naranja">
<small><em>Publicado el <?=$date->format('d');?> de <?= $date->format('F') ?>o del <?= $date->format('Y'); ?> a las <?= $date->format('H:i') ?></em></small>
</div>
<div class="col-md-4 bg-negro-opacity text-naranja d-flex flex-row-reverse">
<small><em>Autor: <?= $array['author']; ?></em></small>
</div>
</div>
<div class="row">
<div class="col-md-12 bg-negro-opacity text-white">
<p><?php echo $array['preview']; ?></p>
</div>
</div>
<div class="row">
<div class="col-md-12 bg-negro-opacity text-naranja rounded-bottom text-center">
<span style="cursor: pointer;" class="font-weight-bold font-italic text-naranja plusNews">Ver la noticia completa</span>
</div>
</div>
</div>
<?php } ?>
This is the form from where I save this info:
<div class="row">
<div class="col-md-12 mt-4">
<div class="card">
<div class="card-header bg-negro text-white">
<h5 class="card-title text-center">Agregar noticia</h5>
</div>
<form class="form" role="form" method="POST" id="form-news">
<input type="hidden" name="dblanguage" value="es_LA">
<div class="card-body bg-gris text-naranja font-weight-bold">
<div class="form-group">
<label for="newsType">Categoría de la noticia</label>
<select class="custom-select" id="newsType" name="newsType" disabled>
<option>Noticia Junebia</option>
</select>
</div>
<div class="form-group">
<label for="newsTitle">Título de la noticia (<span id="maxCharTitle">60</span> caracteres restantes)</label>
<input type="text" name="newsTitle" id="newsTitle" class="form-control" maxlength="60">
</div>
<div class="form-group">
<label for="newsPreview">Texto de vista previa (<span id="maxChar">120</span> caracteres restantes)</label>
<textarea type="text" name="newsPreview" id="newsPreview" class="form-control" maxlength="100"></textarea>
</div>
<div class="form-group">
<label for="newsContent">Contenido de la noticia</label>
<textarea id="newsContent" name="newsContent" class="form-control"></textarea>
</div>
<input type="hidden" name="username" value="<?= $_SESSION['userName'] ?>">
</div>
<div class="container-fluid justify-content-center d-flex bg-gris">
<button type="submit" class="btn btn-naranja btn-lg mb-2" id="btnAgregar">Agregar</button>
</div>
</form>
</div>
</div>
This is my php file to handle that form:
require_once('../database.php');
if(!isBanned() && isAdmin())
{
if(isset($_POST['newsTitle']))
{
$newsTitle = $_POST['newsTitle'];
$newsPreview = $_POST['newsPreview'];
$newsContent = $_POST['newsContent'];
$newsAuthor = $_POST['username'];
$newsTime = date('Y-m-d H:i:s');
$stmt = $mysqli->prepare("INSERT INTO news(title,preview,content,author,timepost) VALUES(?,?,?,?,?)");
$stmt->bind_param('sssss',$newsTitle,$newsPreview,$newsContent,$newsAuthor,$newsTime);
$stmt->execute();
echo true;
}
else
{
echo false;
}
}
else
{
echo false;
}
I'm using bootstrap 4.1
You just need a space and everything will be fine.
But if your text is looks like as you fetch. You can just try the following css with parent div of text:
word-break: break-all;

How to perform search in custom post type page in wordpress

I have a search bar in my FAQ page.
<div class="input-group">
<input class="form-control" placeholder="Search Question Here" type="text">
<span class="input-group-btn">
<button class="btn btn-search" type="button"><i class="fa fa-search"></i></button>
</span>
</div>
All questions are listed below and when the user types in the words corresponding results should be displayed. Here is rest of my page,
$args=array('post_type'=>'questions','post_status'=>'publish','posts_per_page'=>-1,'order'=>'DESC');
$questions=get_posts($args);
<div class="row">
<div class="col-md-3">
<h3 class="faq-cat"><?= $cat->name;?> ?</h3>
</div>
<div class="col-md-9" role="tablist">
<?php
foreach($cat_posts as $catqn)
{
// var_dump($catqn);
?>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<h4 class="panel-title question-heading">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#<?php echo $catqn->ID; ?>" aria-expanded="false" aria-controls="collapseOne" class="collapsed">
<?php echo get_post_meta($catqn->ID,'question',true);?> <strong>?</strong>
<span class="faq-btn faq-btn-minus hidden-xs"><i class="fa fa-caret-down"></i></span>
<span class="faq-btn faq-btn-plus hidden-xs"><i class="fa fa-caret-up"></i></span></a>
</h4>
</div>
<div id="<?php echo $catqn->ID; ?>" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<p><?php echo get_post_meta($catqn->ID,'answer',true);?></p>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
can anyone please guide me through this ? ?
needed to add a hidden custom post type input into the search form.
<form class="search" action="<?php echo home_url( '/' ); ?>">
<input type="search" name="s" placeholder="Search Question Here">
<input type="submit" value="Search" class="btn btn-search">
<input type="hidden" name="post_type" value="questions">
</form>
<div class="input-group">
<form method="post">
<input class="form-control" name="searchx" placeholder="Search Question Here" type="text">
<span class="input-group-btn">
<button class="btn btn-search" name="submit" type="button"><i class="fa fa-search"></i></button>
</span>
</form>
</div>
<?php
if(isset($_POST['submit'])){
$searchword = $_POST['searchx'];
$args=array('post_type'=>'questions','post_status'=>'publish','posts_per_page'=>-1,'s' => $searchword,'order'=>'DESC');
$cat_posts=get_posts($args);
echo "<pre>";print_r($cat_posts);echo "</pre>";
?>
<div class="row">
<div class="col-md-3">
</div>
<div class="col-md-9" role="tablist">
<?php
foreach($cat_posts as $catqn)
{
// var_dump($catqn);
?>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<h4 class="panel-title question-heading">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#<?php echo $catqn->ID; ?>" aria-expanded="false" aria-controls="collapseOne" class="collapsed">
<?php echo get_post_meta($catqn->ID,'question',true);?> <strong>?</strong>
<span class="faq-btn faq-btn-minus hidden-xs"><i class="fa fa-caret-down"></i></span>
<span class="faq-btn faq-btn-plus hidden-xs"><i class="fa fa-caret-up"></i></span></a>
</h4>
</div>
<div id="<?php echo $catqn->ID; ?>" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<p><?php echo get_post_meta($catqn->ID,'answer',true);?></p>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
Try this one please.
You can try this,
<form class="search" action="<?php echo home_url( '/' ); ?>">
<input type="search" name="s" placeholder="Search...">
<input type="submit" value="Search">
<input type="hidden" name="post_type" value="questions">
</form>
Or
You can use an action to edit your Query For Search before it's fire using action pre_get_posts
<?php
function my_pre_get_posts($query) {
if( is_admin() )
return;
if( is_search() && $query->is_main_query() ) {
$query->set('post_type', 'questions');
}
}
add_action( 'pre_get_posts', 'my_pre_get_posts' );
?>
Hope this will helps You.

undefined variable in modal

if i click on view button in my table it should open an modal form and
display all table values to view it.But i'm getting error as undefined
variable in the textbox inside of location,where i called only location
in the table.kindly help out me with how to get datas from dbs as php
code.thanks in advance.
UPDATE: I had updated my code.Kindly check it out,as i called ajax ,but modal box open with empty ,no informations loaded.kindly help it out.
<!-- Main content -->
<div class="main-content">
<h1 class="page-title">OUR POP DETAILS</h1>
<!-- Breadcrumb -->
<ol class="breadcrumb breadcrumb-2">
<li><i class="fa fa-home"></i>Home</li>
<li>Metro Pop</li>
<li class="active"><strong>Action</strong></li>
</ol>
<div class="row">
<div class="col-md-12"></div>
<div class="col-md-4">
<?php $apage = array('id'=>'','name'=>'');?>
<script>var page_0 = <?php echo json_encode($apage)?></script>
<h3><a data="page_0" class="model_form btn btn-sm btn-danger" href="#"><span class="glyphicon glyphicon-plus"></span> Add new record</a></h3>
</div>
</div>
<div id="table-container">
<div class="row">
<div class="col-md-12">
<table id="table" class="table table-striped table-sortable table-condensed " cellspacing="0" width="100%"
data-show-columns="true"
>
<tbody>
<?php if(isset($result) && ($data_record) > 0) : $i=1; ?>
<?php while ($users = mysqli_fetch_object($result)) { ?>
<tr class="<?=$users->id?>_del">
<td><?=$i;?></td>
<td><?=$users->zonee;?></td>
<td><?=$users->location;?></td>
<td><?=$users->pop_type;?></td>
<td><?=$users->switch_name;?></td>
<td><?=$users->switch_ip;?></td>
<td><?=$users->switch_make;?></td>
<td><?=$users->switch_serial;?></td>
<td><?=$users->switch_model;?></td>
<td> <i class="material-icons"></i></td>
<script>var page_<?php echo $users->id ?> = <?php echo json_encode($users);?></script>
<td><a data="<?php echo 'page_'.$users->id ?>" class="model_form btn btn-info btn-sm" href="#"> <span class="glyphicon glyphicon-pencil"></span></a>
<a data="<?php echo $users->id ?>" title="Delete <?php echo $users->name;?>" class="tip delete_check btn btn-info btn-sm "><span class="glyphicon glyphicon-remove"></span> </a>
<button data-toggle="modal" data-target="#view-modal" data-id="<?php echo $users->id; ?>" class=" view_check btn btn-sm btn-info"><i class="glyphicon glyphicon-eye-open"></i></button>
</td>
</tr>
<?php $i++;
} ?>
<?php else : echo '<tr><td colspan="8"><div align="center">-------No record found -----</div></td></tr>'; ?>
<?php endif; ?>
</tbody>
</table>
<?php
if(isset($_SESSION['flash_msg'])) :
$message = $_SESSION['flash_msg'];
echo $error= '<div class="alert alert-success" role="alert">
<span class="glyphicon glyphicon-envelope"></span> <strong>'.$message.'</strong> </div>';
unset($_SESSION['flash_msg']);
endif;
?>
</div>
</div>
</div>
<div id="view-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">
<i class="glyphicon glyphicon-user"></i> POP Information
</h4>
</div>
<div class="modal-body" id="employee_detail">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Form modal -->
<div id="form_modal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"><i class="icon-paragraph-justify2"></i><span id="pop_title">ADD</span> POP INFORMATION</h4>
</div>
<!-- Form inside modal -->
<form method="post" action="add_edit.php" id="cat_form">
<div class="modal-body with-padding">
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>zonee :</label>
<input type="text" name="zonee" id="zonee" class="form-control required">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>location :</label>
<input type="text" name="location" id="location" class="form-control required">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>pop_type :</label>
<input type="text" name="pop_type" id="pop_type" class="form-control required number">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>switch_name:</label>
<input type="text" name="switch_name" id="switch_name" class="form-control required number">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>switch_ip :</label>
<input type="text" name="switch_ip" id="switch_ip" class="form-control required" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>switch_make :</label>
<input type="text" name="switch_make" id="switch_make" class="form-control required" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>switch_serial :</label>
<input type="text" name="switch_serial" id="switch_serial" class="form-control required" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>switch_model :</label>
<input type="text" name="switch_model" id="switch_model" class="form-control required" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>Latitude:</label>
<input type="text" name="latitude" id="latitude" class="form-control required" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>Longitude:</label>
<input type="text" name="longitude" id="longitude" class="form-control required" >
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
<span id="add">
<input type="hidden" name="id" value="" id="id">
<button type="submit" name="form_data" class="btn btn-primary">Submit</button>
</span>
</div>
</form>
</div>
</div>
</div>
<!-- /form modal -->
<script type="text/javascript">
$(document).ready(function() {
$(document).on('click','.model_form',function(){
$('#form_modal').modal({
keyboard: false,
show:true,
backdrop:'static'
});
var data = eval($(this).attr('data'));
$('#id').val(data.id);
$('#zonee').val(data.zonee);
$('#location').val(data.location);
$('#pop_type').val(data.pop_type);
$('#switch_name').val(data.switch_name);
$('#switch_ip').val(data.switch_ip);
$('#switch_make').val(data.switch_make);
$('#switch_serial').val(data.switch_serial);
$('#switch_model').val(data.switch_model);
$('#latitude').val(data.latitude);
$('#longitude').val(data.longitude);
if(data.id!="")
$('#pop_title').html('Edit');
else
$('#pop_title').html('Add');
});
$(document).on('click','.delete_check',function(){
if(confirm("Are you sure to delete data")){
var current_element = $(this);
url = "add_edit.php";
$.ajax({
type:"POST",
url: url,
data: {ct_id:$(current_element).attr('data')},
success: function(data) { //location.reload();
$('.'+$(current_element).attr('data')+'_del').animate({ backgroundColor: "#003" }, "slow").animate({ opacity: "hide" }, "slow");
}
});
}
});
$(document).on('click', '.view_check', function(){
//$('#dataModal').modal();
var employee_id = $(this).attr("id");
$.ajax({
url:"view.php",
method:"POST",
data:{employee_id:employee_id},
success:function(data){
$('#employee_detail').html(data);
$('#view-modal').modal('show');
}
});
});
});
});
</script>
**view.php**
<?php
include("config.php");
if(isset($_POST["employee_id"]))
{
$output = '';
$connect = mysqli_connect("localhost", "root", "", "mine");
$query = "SELECT * FROM user WHERE id = '".$_POST["employee_id"]."'";
$result = mysqli_query($connect, $query);
$output .= '
<div class="table-responsive">
<table class="table table-bordered">';
while($row = mysqli_fetch_object($result))
{
$output .= '
<tr>
<td width="30%"><label>Name</label></td>
<td width="70%">'.$users["location"].'</td>
</tr>
<tr>
<td width="30%"><label>Address</label></td>
<td width="70%">'.$users["zonee"].'</td>
</tr>
<tr>
<td width="30%"><label>Gender</label></td>
<td width="70%">'.$users["pop_type"].'</td>
</tr>
';
}
$output .= '</table></div>';
echo $output;
}
?>
Add quota('') like $row['location'] , you are using $row[location]
Or use below code
<div class="col-sm-12">
<label>location :</label>
<input type="text" name="location" id="location" value="<?php
echo $row['location'];?>" />
</div>
Your variable name is $users not $row so you can write this
<div class="form-group">
<div class="row">
<div class="col-sm-12">
<label>location :</label>
<input type="text" name="location" id="location" value="<?php
echo $users['location'];?>" />
</div>
Try this Code
<tbody>
<?php if(isset($result) && ($data_record) > 0) : $i=1; ?>
<?php while ($users = mysqli_fetch_object($result)) { ?>
<tr class="<?=$users->id?>_del">
<td><?=$i;?></td>
<td><?=$users->zonee;?></td>
<td><?=$users->location;?></td>
<td><?=$users->pop_type;?></td>
<td><?=$users->switch_name;?></td>
<td><?=$users->switch_ip;?></td>
<td><?=$users->switch_make;?></td>
<td><?=$users->switch_serial;?></td>
<td><?=$users->switch_model;?></td>
<td> <a href="http://maps.google.com/?q=<?=$users-
>latitude;?>,<?=$users->longitude;?>" target=\"_blank\"><i
class="material-icons"></i></a></td>
<script>var page_<?php echo $users->id ?> = <?php
echo json_encode($users);?></script>
<td><a data="<?php echo 'page_'.$users->id ?>"
class="model_form btn btn-info btn-sm" href="#"> <span
class="glyphicon glyphicon-pencil"></span></a>
<a data="<?php echo $users->id ?>" title="Delete <?
php echo $users->name;?>" class="tip delete_check btn btn-info
btn-sm "><span
class="glyphicon glyphicon-remove"></span> </a>
<button data-toggle="modal" data-target="#view-
modal" data-id="<?php echo $users->id; ?>" id="getUser"
class="btn btn-sm
btn-info"><i class="glyphicon glyphicon-eye-open"></i>
</button>
</td>
</tr>
<?php $i++;
echo "<div class='modal-body'>
<div id='dynamic-content'>
<div class='form-group'>
<div class='row'>
<div class='col-sm-12'>
<label>location :</label>
<input type='text' name='location' id='location' value='$users->location' />
</div>
</div>
</div>
</div>
</div> "
} ?>
<?php else : echo '<tr><td colspan="8"><div align="center">-------No
record found -----</div></td></tr>'; ?>
<?php endif; ?>
</tbody>
On Click Call Function
<script>
function launch_modal(id)
{
//Store id in variable
var newId = id;
//Ajax Start
$.ajax({
type: "POST",
url: "your_php_page.php",
//send id to php page
data: {theId:newId},
success: function(data){
//to display data in paragraph of Modal
$('.modal-body').html(data);
//to display modal
$('#myModal').modal("show");
},
});
}
</script>
your_php_page.php
<?php
$theId = $_POST['theId'];
if($theId){
$output = '';
$sql = $conn->query("select * from table where id = '$theId'");
$fetch = $sql->fetch_object();
//Append
$output .= '<table class="table table-bordered">
<tr>
<td>Name :</td>
<td>'.$fetch->name.'</td>
</tr>
<tr>
<td>Number :</td>
<td>'.$fetch->number.'</td>
</tr>
';
echo $output;
}
?>

Bootstrap panel not getting extended

I am using bootstrap 3 and I am making a social networking site, this code here is a part of a panel which shows the posts.The problem is it is showing the comments on toggle but the comments are not appearing within the footer it is crossing it...So what is wrong in my or how can I extend the panel footer?
Here's the code:
<div class="panel-footer">
Like <span class="glyphicon glyphicon-thumbs-up"></span>
Comments
<div id='toggleComment<?php echo $idp;?>' style="display:none;">
<form action="" method="POST"><!--FORM COMMENT-->
<div class="form-group">
<div class="rows" >
<div class="col-sm-1" style="padding-right:2px;">
<div class="compic">
<img src="<?php echo $profilepic; ?>" style="width:100%;height:100%;" />
</div>
</div>
<div class="col-sm-11" style="padding-left:3px; padding-bottom:7px">
<textarea class="form-control expandable pull-left" name="comment<?php echo $idp;?>" id="comment" placeholder="Write a comment..." required>
</textarea>
</div>
</div>
<hr>
<button type="submit" class="btn btn-primary pull-right" name="subcom<?php echo $idp;?>"><b>Comment</b></button>
<div class="clearfix"></div>
</div></form>
<div class="rows" >
<?php
$postid=$idp;
$postby=$id;
$postto=$uid;
if(isset($_POST['subcom'.$postid]))
{ $postbody=$_POST['comment'.$postid];
if($postbody!="")
{$res=mysqli_query($con,"INSERT INTO comment VALUES('','$postby','$postto','$postbody','$postid')");}
}
$show=mysqli_query($con,"SELECT * FROM comment WHERE postid='$idp' ORDER by id");
while($show_row=mysqli_fetch_array($show))
{
$commentbyid=$show_row['cby'];
$combody=$show_row['cbody'];
$cbyquery=mysqli_query($con,"SELECT * FROM user WHERE id='$commentbyid'") or die(mysqli_error($con));
$cby=mysqli_fetch_array($cbyquery);
$cpic=$cby['profpic'];
if ($cpic== "" || !file_exists("userdata/profile_pics/$cpic"))
{
$cpic = "images/default_pic.jpg";
}
else
{
$cpic = "userdata/profile_pics/".$cpic;
}
$cname=ucfirst(strtolower($cby[1]));
$csname=ucfirst(strtolower($cby[2]));
?>
<div class="col-sm-1" style="padding-right:2px;">
<div class="compic">
<img src="<?php echo $cpic; ?>" style="width:100%;height:100%;" />
</div>
</div>
<div class="col-sm-11" style="padding-left:3px;">
<?php echo $cname." ".$csname;?><br>
<?php echo $combody;?>
</div>
<?php
}
?></div>
</div><!--Toggle Ends here-->
</div>
finally got it it was because of the <div class="clearfix"></div> and it got solved when I used it just after </div><!--Toggle Ends here-->

Categories