I want to show all the users who's status is 0 are showing in the table. With every user data there is a detail button when admin click on this detail all the information about users are show in the form. After watching all the information of user, Admin take action with "VERIFY" OR "REJECTED" user The issue is when the data is increased in the table the "Verify" & "Rejected" links are also increased in the form How to solve this issue.
User Data in Table:
Issue:
View:
<div class="imageGallery" style="height: auto; width: 75%; /*background:grey;*/ margin: 0px auto;">
<?php foreach($gallery as $image):?>
<div class="image" style=" width:100%; max-width:205px; display: inline-block;" >
<img src="<?php if($image['path'] !=null){ echo base_url()."assets/users/".$image['user_id']."/".$image['path'];}?>" style="width:200px; height:200px; padding:5px; margin-left: 110px "/>
</div>
<?php endforeach;?>
</div>
<!--<input type="hidden" name="id" value=?>">-->
<div class="row" style="padding-top: 30px; padding-bottom: 30px;">
<div class="col-sm-6 col-sm-offset-3" style="margin-left: 344px">
<?php foreach($users as $user):?>
<a style="text-decoration: none; float: right" href="<?php echo base_url();?>verifyUserEmail/<?php echo $user->email; ?>/<?php echo $user->id; ?>" class="btn btn-link">Verify</a>
<a style="text-decoration: none; float: right" href="<?php echo base_url();?>rejectedUser/<?php echo $user->email; ?>/<?php echo $user->id; ?>" class="btn btn-link">Rejected</a>
<?php endforeach; ?>
<button type="submit" class="btn btn-default" style="float: right;">Update</button>
</div>
</div>
Controller:
function editUser($id)
{
{
$data["userdetail"] = $this->AdminModel->getUserDetails($id);
$data["gallery"] = $this->AdminModel->getUserGallery($id);
$data['users'] = $this->AdminModel->getRoleStatusUsers();
$this->load->view('Admin/includes/header');
$this->load->view('User/edituser', $data);
$this->load->view('Admin/includes/footer');
}
}
Model:
public function userEdit($id, $data){
$this->db->where('id', $id);
$result = $this->db->update('mh_users', $data);
if ($result === FALSE)
{
show_error('error !');
}
return $result;
}
public function getUserDetails($id){
$this->db->select()->from('mh_users')->where('id',$id)->limit(1);
$query = $this->db->get();
return $query->result_array();
}
public function getUserGallery($id){
$this->db->select()->from('mh_user_media')->where('user_id',$id);
$query = $this->db->get();
return $query->result_array();
}
Because you have your "verify" and "rejected" buttons in a foreach loop, they will get duplicated for every user you have. So if you have 10 users, you will have 10 pairs of "verify" and "rejected" buttons.
Simply remove the buttons from the foreach loop to remove the duplicates i.e.
<div class="row" style="padding-top: 30px; padding-bottom: 30px;">
<div class="col-sm-6 col-sm-offset-3" style="margin-left: 344px">
<a style="text-decoration: none; float: right" href="<?php echo base_url();?>verifyUserEmail/<?php echo $user->email; ?>/<?php echo $user->id; ?>" class="btn btn-link">Verify</a>
<a style="text-decoration: none; float: right" href="<?php echo base_url();?>rejectedUser/<?php echo $user->email; ?>/<?php echo $user->id; ?>" class="btn btn-link">Rejected</a>
<button type="submit" class="btn btn-default" style="float: right;">Update</button>
</div>
</div>
To ensure you are passing the correct user information, pass a specific user to the view/form rather than an array/object of users.
Related
I want to display through the user's photo relationships but it does not show
And this photo also exists, but when I take dd(), it says null
this is Blade code And they all work except the user_image
#foreach($threads as $thread)
<div class="card my-3 rounded-lg mr- ">
<div class="card-body shadow ">
<blockquote class="blockquote mb-0">
<div class=" d-flex">
<p style="font-size: x-large; font-weight: bold; "><a class="" href="/threads/{{$thread->slug}}">{{\Illuminate\Support\Str::limit($thread->title,50)}}</a>
</p>
</div>
<div class=" d-flex">
<img class="img-profile rounded-circle mr-1 " style="width: 60px; height: 60px;"
src="{{$thread->user->user_image}}"> {{-- this is not working--}}
<p class="mt-3 text-secondary"
توسط {{$thread->user->name}} آپدیت شد</p>
</div>
<footer
class="blockquote-footer text-dark">{{\Illuminate\Support\Str::limit($thread->description,150)}}
</blockquote>
</div>
</div>
#endforeach
Maybe replace
public function user()
{
return $this->belongsTo(User::class);
}
by something like
public function images()
{
return $this->belongsTo(User::class);
}
and for users do
hasMany (images)
Also you have to do migrations to add foreign keys, did you do this ?
It uploads multiple images in database with below code as well as in admin panel but the problem is the images does not appear in laravel web page means it displays one image replace another image. Pls anyone can help me.
CMS Controller
public function store(Request $request)
{
$ginput = [];
if($request->hasFile('gallery')){
$files = $request->file('gallery');
foreach ($files as $file) {
$ginput[] = ImageUpload::upload('/upload/cms',$file);
}
$input['gallery'] = implode(',', $ginput);
}
}
Form.blade
<div class="col-md-12">
<p>Gallery Image</p>
<div class="col-md-6 col-md-offset-3">
<input type="file" name="gallery_multiple[]" class="form-control" multiple="multiple">
</div><br><br>
<p class="text-center">- OR -</p>
</div>
#if(isset($cms) && !empty($cms->gallery))
<?php
$galleryArray = explode(',', $cms->gallery);
?>
#if(!empty($galleryArray) && count($galleryArray) > 0)
#foreach($galleryArray as $gallery)
<div class="col-md-3 mb-4 gallery-image-parent">
<input class="upload property-image-input" type="hidden" value="{{ $gallery }}">
<div class="fuzone">
<div class="fu-text" style="margin: 0px;height: 100%;">
<img src="{{ asset('/upload/cms/'.$gallery) }}" class="property-image-preview">
</div>
<i style="background-color: red; color: #fff; height: 30px !important; width: 30px !important; border-radius: 50% !important; padding-top: 5px !important; position: relative !important; top: -160px !important; right: -92px !important;" class="fa fa-trash-o gallery-image-remove" data-page-type="{{ !isset($cms) ? 'create' : 'edit' }}" data-id="{{ $cms->id }}" data-image-name="{{ $gallery }}" style="font-size: 20px;top: -165px;"></i>
</div>
</div>
#endforeach
#endif
My viewis like below.
<div class="carousel-inner">
<?php
foreach($news_data as $nws){
?>
<div class="item **If this is the first row, then echo active**">
<div class="col-md-12 news-item" style="padding-left: 0;">
<p><?php echo $nws->news_desc; ?></p>
</div>
</div>
<?php } ?>
</div>
Model:
function get_news_update()
{
$this->db->select('news_desc');
$this->db->from('news');
$this->db->where('stat', '1');
$this->db->order_by('id', 'desc');
$query = $this->db->get();
return $query->result();
}
Please see the <div class="item. If it is the first row of query result, then it will be item active.
How to do that ?
Modify your view like this:
<div class="carousel-inner">
<?php
foreach($news_data as $key => $nws){
?>
<div class="item <?php echo $key == 0 ? "active":""; ?>">
<div class="col-md-12 news-item" style="padding-left: 0;">
<p><?php echo $nws->news_desc; ?></p>
</div>
</div>
<?php } ?>
</div>
Here is your updated code
<div class="carousel-inner">
<?php
$i = 0;
foreach($news_data as $nws){
// it should be $i. not $i%2 right ?
if($i == 0)
{
$class="item active";
}
else
{
$class = "item";
}
?>
<div class="<?php echo $class; ?>">
<div class="col-md-12 news-item" style="padding-left: 0;">
<p><?php echo $nws->news_desc; ?></p>
</div>
</div>
<?php $i++; } ?>
</div>
As per my knowledge,You are looking for below code.Please let me know if its not working.
function get_news_update()
{
$this->db->select('news_desc');
$this->db->from('news');
$this->db->where('stat', '1');
$this->db->order_by('id', 'desc');
$query = $this->db->get();
return $query->first_row();
}
You can use row() function, which return always the first result.
Model.php
function get_news_update(){
$this->db->select('news_desc');
$this->db->from('news');
$this->db->where('stat', '1');
$this->db->order_by('id', 'desc');
$query = $this->db->get();
//check if exist
if (isset($query->row())){
return $query->row();
}
}
For more informations you will find here
View.php
<div class="carousel-inner">
<div class="item **If this is the first row, then echo active**">
<div class="col-md-12 news-item" style="padding-left: 0;">
<p><?php echo $nws->news_desc; ?></p>
</div>
</div>
</div>
i try all of away that i know and suggestion on internet.
but all time return false.
please help me...
thanks
my error message is:
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/index.php
Line Number: 10
model.php
public function getBanner()
{
$this->db->select('album.id, album.cat_id , album.poster, album.slug, album.modify, category.id, category.name, category.slug');
$this->db->from('album,category');
$this->db->where('album.cat_id', 'category.id');
$query = $this->db->get();
if($query->num_rows() != 0)
{
$result = $query->result_array();
return $result;
}
else
{
return false;
}
}
controllers.php
$data['banner'] = $this->Fornt_model->getBanner();
showbanner.php
<section class="banner">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<?php $item = 1; foreach($banner as $latest_poster): $item_class = ($item == 1) ? 'item active' : 'item'; ?>
<div class="<?php echo $item_class; ?>">
<img src="<?php echo base_url('images/poster/'.$latest_poster['poster']); ?>" class="img-responsive img-thumbnail">
<div class="carousel-caption caption">
<a href="<?php echo site_url('category/bollywood/'.$latest_poster['slug']); ?>" class="box">
<b class="h3"><?php echo $latest_poster['name']; ?></b>
<small class="p">Exclusive AT*<?php echo substr($latest_poster['modify'], 0, 10); ?></small>
</a>
</div>
</div>
<?php $item++; endforeach; ?>
</div>
</div>
</div>
</div>
<div class="clearfix" style="padding: 10px 0;"></div>
<div class="row hidden-xs">
<?php $itemto = 0; foreach($banner as $latest_poster): $item_class_active = ($itemto == 0) ? 'active' : ''; ?>
<div class="col-sm-2 pointer" data-target="#myCarousel" data-slide-to="<?php echo $itemto; ?>"><img src="<?php echo base_url('images/poster/'.$latest_poster['poster']); ?>" class="img-responsive img-thumbnail" /></div>
<?php $itemto++; endforeach; ?>
</div>
</div>
I think something wrong with your query.. try
if($query->num_rows() != 0)
{
$result = $query->result_array();
print_r($result);
}
make sure your array data is available..
If there is no rows, front_model->getBanner() will return the result as false. Due to this you are getting an error. Use following code
public function getBanner()
{
$this->db->select('album.id, album.cat_id , album.poster, album.slug, album.modify, category.id, category.name, category.slug');
$this->db->from('album,category');
$this->db->where('album.cat_id', 'category.id');
$query = $this->db->get();
return $query->result_array();
}
I am creating an online restaurant order system. I am using codeigniter. In the order page I have used the angular grid system which filters and sorts the items.
What I want to do is create a checkbox in every row. The checkboxes I click the item corresponding to them should be added to cart. I am using codeigniter cart class.
My code is as follow.
<html ng-app="myApp" ng-app lang="en"><head>
<title>Wah Bhai Wah</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>css/animate.css">
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>css/bootstrap.css">
<script type="text/javascript" src="<?php echo base_url() ?>js/jquery.js"></script>
<script type="text/javascript" src="<?php echo base_url() ?>js/java.js"></script>
<script type="text/javascript" src="<?php echo base_url() ?>queries/insert_into_cart.js"></script>
<script type="text/javascript" src="<?php echo base_url() ?>js/bootstrap.js"></script>
<script type="text/javascript">
$(document).on("click", ".view_link", function() {
var id = $(this).data('id');
$(".modal-body #itemid").val( id );
var name = $(this).data('name');
$(".modal-body #itemname").val( name );
document.getElementById("descmodallabel").innerHTML = name;
var image = $(this).data('image');
document.getElementById("itemimagesrc").src = image;
$(".modal-body #itemimage").val( image );
var price = $(this).data('price');
$('.modal-body #itemprice').val( price );
});
</script>
</head>
<style>
.a
{
background-color:white;
}
body{
background: url("http://localhost/wah/images/slider/M3.png") fixed 100% 100%; background-size: cover;
}
.d{
background-color: green; height: 200px;
}
.c
{
background-color: yellow; height: 600px;
}
.item{
background-color: white; padding: 10px; margin-bottom: 20px;
box-shadow: 5px;-webkit-box-shadow: 0px 10px 45px 6px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 10px 45px 6px rgba(0,0,0,0.75);
box-shadow: 0px 10px 45px 6px rgba(0,0,0,0.75); border-radius: 6px;
}
.main
{
margin-top:200px;
}
.side-nav{background-color: white; padding: 30px; top:100px; }
table{
border-spacing: 0px;
border-collapse: separate;
}
td
{
padding-right: 20px; padding-top:10px;
}
.forms{background-color:white; padding-right:20px; margin-top:200px; position:static;}
</style>
<body>
<div class="modal fade" id="myModalmenu" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Menu</h4>
</div>
<div class="modal-body">
<table>
<tr>
<td>Item</td>
<td>Cost</td>
</tr><?php
foreach ($i as $items) {
?>
<tr>
<td>
<img src="<?php echo $items->img ?>" height="50px" width="50px">
<?php echo " ".ucfirst($items->item_name); ?>
</td>
<td>
<?php echo $items->price ?>
</td>
</tr>
<?php
}
?>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade in" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Cart</h4>
</div>
<div class="modal-body">
<table>
<tr><td>Item</td><td>Qty</td><td>Price</td><td>Total</td></tr>
<?php foreach($this->cart->contents() as $cart_items){ ?>
<tr>
<?php $id = $cart_items['rowid']; ?>
<?php echo form_open('cart_test/update/'.$id); ?>
<td><?php echo $cart_items['name'] ?></td>
<td><input type="number" class="span1" id="qty" value = "<?php echo $cart_items['qty'] ?>" name="qty"></td>
<td><?php echo $cart_items['price'] ?></td>
<td><?php echo $cart_items['subtotal'] ?> </td>
</tr>
<tr>
<td>
Remove
</td>
<td>
<input type="submit" value="Update" class="btn btn-primary">
</td>
</form>
</tr>
<?php } ?>
<tr><td colspan="5" ><hr style="background-color: #000000"></td></tr>
<tr><td colspan="2">Item Total</td><td colspan="2"><b style="text-align: right"><?php echo $this->cart->total_items()?></b></td></tr>
<tr><td colspan="2">Bill Total</td><td colspan="2"><b style="text-align: right"><?php echo $this->cart->total()?></b></td></tr>
<tr><td colspan="5" ><hr style="background-color: #000000"></td></tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<?php
if($this->cart->total_items()==0)
{
?>
Proceed To Checkout
<?php
}
else
{
?>
Proceed To Checkout
<?php
}
?>
</div>
</div>
</div>
</div>
<nav role="navigation" class="navbar navbar-default navbar-fixed-top">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
Wah Bhai Wah
</div>
<!-- Collection of nav links, forms, and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li >Home</li>
<li class="active">order</li>
<li>Menu</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Logout</li>
<li><a href="#" data-toggle="modal" data-target="#myModal">View Cart <b style="background-color:red; -moz-border-radius: 45px;
-webkit-border-radius: 45px;
border-radius: 450px; padding:15px;" ><?php echo count($this->cart->contents()) ?></b></a></li>
</ul>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div ng-controller="customersCrtl" class="main">
<div class="container">
<div class="row">
<div class="col-md-2">PageSize:
<select ng-model="entryLimit" class="form-control">
<option>5</option>
<option>10</option>
<option>20</option>
<option>50</option>
<option>100</option>
</select>
</div>
<div class="col-md-3">Filter:
<input type="text" ng-model="search" ng-change="filter()" placeholder="Filter" class="form-control" />
</div>
</div>
<br/>
<div class="row">
<div class="col-md-12" ng-show="filteredItems > 0">
<table class="table table-condensed active" style="background-color:white; border-radius:6px; padding:20px;">
<thead>
<th class="success">Item Id <a ng-click="sort_by('id');"><i class="glyphicon glyphicon-sort"></i></a></th>
<th class="danger">Item Name <a ng-click="sort_by('item_name');"><i class="glyphicon glyphicon-sort"></i></a></th>
<th class="danger">Item <a ng-click="sort_by('img');"><i class="glyphicon glyphicon-sort"></i></a></th>
<th class="danger">Price <a ng-click="sort_by('price');"><i class="glyphicon glyphicon-sort"></i></a></th>
<th class="danger">Category <a ng-click="sort_by('category');"><i class="glyphicon glyphicon-sort"></i></a></th>
</thead>
<tbody>
<tr ng-repeat="data in filtered = (list | filter:search | orderBy : predicate :reverse) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit" class="danger">
<td>{{data.id}}</td>
<td>{{data.item_name}}</td>
<td><img src={{data.img}} height="50px" width="50px"></td>
<td>{{data.price}}</td>
<td>{{data.category}}</td>
<td>Add to Cart</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-12" ng-show="filteredItems == 0">
<div class="col-md-12">
<h4>No Items found</h4>
</div>
</div>
<div class="col-md-12" ng-show="filteredItems > 0">
<div pagination="" page="currentPage" on-select-page="setPage(page)" boundary-links="true" total-items="filteredItems" items-per-page="entryLimit" class="pagination-small" previous-text="«" next-text="»"></div>
</div>
</div>
</div>
</div>
<script src="<?php echo base_url() ?>apps/js/angular.min.js"></script>
<script src="<?php echo base_url() ?>apps/js/ui-bootstrap-tpls-0.10.0.min.js"></script>
<script src="<?php echo base_url() ?>apps/app/app.js"></script>
<!-- Button trigger modal -->
<!-- Modal -->
<div class="modal fade" id="descmodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="descmodallabel"></h4>
</div>
<div class="modal-body">
<?php echo form_open('cart_test/add_from_desc') ?>
<input type="hidden" src="" value="" id="itemimage" >
<img src="" height="200" width="300px" id="itemimagesrc">
<input type="hidden" name="item_id" value="" id="itemid">
<input type="hidden" name="item_name" value="" id="itemname">
<input type="text" name="item_price" value="" id="itemprice">
<input type="number" name="quantity" value="" required>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Add to Cart</button>
</form>
</div>
</div>
</div>
</div>
</div>
</body
></html>