append not inserting values - php

here my problem is the values that are selected through append are not getting inserted in to the post value..here am pasting my code
<div id="update_new_<?php echo $value->id;?>" class="update_new_<?php echo $value->id;?>">
<div class="form-group mb0" style="margin-bottom: 0px">
<label for="field-1"
class="col-sm-4 control-label">Other Document</label>
<div class="col-sm-5">
<div class="fileinput fileinput-new" data-provides="fileinput">
<?php
if (!empty($value->documents)) {
$uploaded_file = json_decode($value->documents);
}
if (!empty($uploaded_file)):foreach ($uploaded_file as $v_files_image): ?>
<div class="">
<input type="hidden" name="fileName[]"
value="<?php echo $v_files_image ?>">
<span class=" btn btn-default btn-file">
<span class="fileinput-filename"> <?php echo $v_files_image ?></span>
×
</span>
<strong>
<a href="javascript:void(0);" class="RCF"><i
class="fa fa-times"></i> Remove</a></strong>
<p></p>
</div>
<?php endforeach; ?>
<?php else: ?>
<span class="btn btn-default btn-file"><span
class="fileinput-new">Select File</span>
<span class="fileinput-exists"><?= lang('change') ?></span>
<input type="file" name="files[]">
</span>
<span class="fileinput-filename"></span>
<a href="#" class="close fileinput-exists" data-dismiss="fileinput"
style="float: none;">×</a>
<?php endif; ?>
</div>
<div id="msg_pdf" style="color: #e11221"></div>
</div>
<div class="col-sm-3">
<strong><a href="javascript:void(0);" id="update_more" onclick="add_field('<?php echo $value->id;?>');" u_id="<?php echo $value->id;?>" class="addCF update_more_<?php echo $value->id;?>"><i
class="fa fa-plus"></i> Add More
</a></strong>
</div>
</div>
</div>
here is my script please have a look
<script type="text/javascript">
var maxAppends = 0;
function add_field(id)
{
var update_new = $('<div class="form-group" style="margin-bottom: 0px">\n\
<label for="field-1" class="col-sm-4 control-label">Documentsss</label>\n\
<div class="col-sm-5">\n\
<div class="fileinput fileinput-new" data-provides="fileinput">\n\
<span class="btn btn-default btn-file"><span class="fileinput-new">Select file</span><span class="fileinput-exists" >Change</span><input type="file" name="files[]" ></span> <span class="fileinput-filename"></span>×</div></div>\n\<div class="col-sm-2">\n\<strong>\n\<i class="fa fa-times"></i> Remove</strong></div>');
maxAppends++;
$(".update_new_"+id).append(update_new);
}
</script>
Here while clicking to add more fields its coming correctly but the values selected in that field is not getting while passing the value through post and i have a doubt that if it is caused by using dynamic way off adding the data.
The problem i figured out is the problem is the <div id="update_new_<?php echo $value->id;?>"> is inside a foreach loop so how can we done this with in a foreach loop.

In your script, change .update_new_ to #update_new_

Related

How to sort product by product category php

I have a problem with this part of my code.I have column with categories of a products in database of my site, but I can't sort them by this categories. I want to sort them before they show in the store page! I want to show only products with category - women or only with category man! This is my code for now and i don't know what to do. Please, help me! This is import in bigger html code!
<?php
$results = $mysqli->query("SELECT * FROM woman_t_shirts ORDER BY id ASC");
if($results){
$products_item = '<div class="row shop_wrapper">';
//fetch results set as object and output HTML
while($obj = $results->fetch_object())
{
$products_item .= <<<EOT
<div class="col-lg-4 col-md-4 col-12 ">
<div class="single_product"> <form method="post" action="cart_update.php">
<div class="product_thumb">
<a class="primary_img" href="product-details.html"><img src="assets/img/product/exillys/{$obj->product_img_name}" alt=""></a>
<a class="secondary_img" href="product-details.html"><img src="assets/img/product/exillys/{$obj->product_img_name}" alt=""></a>
<div class="product_action">
<div class="hover_action">
<i class="fa fa-plus"></i>
<label>
<input type="hidden" name="product_qty" value="1" size="2" maxlength="2"/>
</label>
<input type="hidden" name="product_code" value="{$obj->product_code}" />
<input type="hidden" name="type" value="add" />
<input type="hidden" name="return_url" value="{$current_url}" />
<div class="action_button">
<ul>
<li><button type="submit" class="add_to_cart" > <i class="fa fa-shopping-basket" aria-hidden="true" style="font-size: 16pt"></i><br></button></li> <br><br>
<li><i class="fa fa-heart-o" aria-hidden="true"></i></li>
</ul>
</div>
</div>
</div>
<div class="quick_button">
+ quick view
</div>
<div class="double_base">
<div class="product_sale">
<span>-7%</span>
</div>
<div class="label_product">
<span>new</span>
</div>
</div>
</div>
<div class="product_content grid_content">
<h3><a>{$obj->product_name}</a></h3>
<span class="current_price">{$obj->price}</span>
<span class="old_price">{$obj->price_not_sale}</span>
</div>
<div class="product_content list_content">
<h3><a>{$obj->product_name}</a></h3>
<div class="product_price">
<span class="current_price">{$obj->price}</span>
<span class="old_price">{$obj->price_not_sale}</span>
</div>
<div class="product_desc">
<p>{$obj->product_desc}</p>
</div>
</div>
</form>
</div>
</div>
EOT;
} }
$products_item .= '</div>';
echo $products_item;
?>

Value are not storing in database

When i put the value from this page its not saving my value in database. The program stopped on this link www.mywebsite.com/index.php?admin/manage_language/update_phrase/english and show a blank page. whenever i run on my local machine its run successfully. update the record and come back to again on www.mywebsite.com/index.php?admin/manage_language/edit_phrase/english on this link. But on my cpanel its not working well.
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<ul class="nav nav-tabs nav-bordered mb-3">
<?php if(isset($edit_profile)):?>
<li class="nav-item">
<a href="#edit" data-toggle="tab" aria-expanded="true" class="nav-link active">
<?php echo get_phrase('edit_phrase');?>
</a>
</li>
<?php endif;?>
<li class="nav-item">
<a href="#list" data-toggle="tab" aria-expanded="false" class="nav-link <?php if(!isset($edit_profile))echo 'active';?>">
<i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
<span class="d-none d-lg-block"><?php echo get_phrase('language_list');?></span>
</a>
</li>
<li class="nav-item">
<a href="#add" data-toggle="tab" aria-expanded="true" class="nav-link">
<i class="mdi mdi-account-circle d-lg-none d-block mr-1"></i>
<span class="d-none d-lg-block"><?php echo get_phrase('add_phrase');?></span>
</a>
</li>
<li class="nav-item">
<a href="#add_lang" data-toggle="tab" aria-expanded="false" class="nav-link">
<i class="mdi mdi-settings-outline d-lg-none d-block mr-1"></i>
<span class="d-none d-lg-block"><?php echo get_phrase('add_language');?></span>
</a>
</li>
</ul>
<div class="tab-content">
<!----PHRASE EDITING TAB STARTS-->
<?php if (isset($edit_profile)):?>
<div class="tab-pane show active" id="edit" style="padding: 30px">
<div class="">
<div class="row">
<?php
$current_editing_language = $edit_profile;
echo form_open(base_url() . 'index.php?admin/manage_language/update_phrase/english' , array('id' => 'phrase_form'));
$count = 1;
$language_phrases = $this->db->query("SELECT `phrase_id` , `phrase` , `$current_editing_language` FROM `language`")->result_array();
foreach($language_phrases as $row)
{
$count++;
$phrase_id = $row['phrase_id']; //id number of phrase
$phrase = $row['phrase']; //basic phrase text
$phrase_language = $row[$current_editing_language]; //phrase of current editing language
?>
<!----phrase box starts-->
<div class="col-md-12">
<div class="tile-stats tile-gray">
<div class="icon"><i class="entypo-mail"></i></div>
<h5><?php echo $row['phrase'];?></h5>
<p>
<input type="text" name="phrase<?php echo $row['phrase_id'];?>"
value="<?php echo $phrase_language;?>" class="form-control"/>
</p>
</div>
</div>
<!----phrase box ends-->
<?php
}
?>
</div>
<input type="hidden" name="total_phrase" value="<?php echo $count;?>" />
<input type="submit" value="<?php echo get_phrase('update_phrase');?>" onClick="document.getElementById('phrase_form').submit();" class="btn btn-primary"/>
<?php
echo form_close();
?>
</div>
</div>
<?php endif;?>
<!----PHRASE EDITING TAB ENDS-->
<!----TABLE LISTING STARTS-->
<div class="tab-pane <?php if(!isset($edit_profile))echo 'show active';?>" id="list">
<div class="table-responsive-sm">
<table class="table table-bordered table-centered mb-0">
<thead>
<tr>
<th><?php echo get_phrase('language');?></th>
<th><?php echo get_phrase('option');?></th>
</tr>
</thead>
<tbody>
<?php
$fields = $this->db->list_fields('language');
foreach($fields as $field)
{
if($field == 'phrase_id' || $field == 'phrase')continue;
?>
<tr>
<td><?php echo ucwords($field);?></td>
<td>
<a href="<?php echo base_url();?>index.php?admin/manage_language/edit_phrase/<?php echo $field;?>"
class="btn btn-info">
<?php echo get_phrase('edit_phrase');?>
</a>
<a href="<?php echo base_url();?>index.php?admin/manage_language/delete_language/<?php echo $field;?>"
class="btn btn-danger">
<?php echo get_phrase('delete_language');?>
</a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<!----TABLE LISTING ENDS--->
<!----PHRASE CREATION FORM STARTS---->
<div class="tab-pane box" id="add" style="padding: 30px">
<div class="box-content">
<?php echo form_open(base_url() . 'index.php?admin/manage_language/add_phrase/' , array('class' => 'form-horizontal form-groups-bordered validate', 'style' => 'width:100%;'));?>
<div class="padded">
<div class="form-group justify-content-md-center">
<label class="col-3 control-label"><?php echo get_phrase('phrase');?></label>
<div class="col-5">
<input type="text" class="form-control" name="phrase" data-validate="required" data-message-required="<?php echo get_phrase('value_required');?>" placeholder="e.g. name, email"/>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-5">
<button type="submit" class="btn btn-info"><?php echo get_phrase('add_phrase');?></button>
</div>
</div>
<?php echo form_close();?>
</div>
</div>
<!----PHRASE CREATION FORM ENDS--->
<!----ADD NEW LANGUAGE---->
<div class="tab-pane box" id="add_lang" style="padding: 30px">
<div class="box-content">
<?php echo form_open(base_url() . 'index.php?admin/manage_language/add_language/' , array('class' => 'form-horizontal form-groups-bordered validate', 'style' => 'width:100%;'));?>
<div class="padded">
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo get_phrase('language');?></label>
<div class="col-sm-5">
<input type="text" class="form-control" name="language" data-validate="required" data-message-required="<?php echo get_phrase('value_required');?>" placeholder="e.g. Spanish, Portugese"/>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-5">
<button type="submit" class="btn btn-info"><?php echo get_phrase('add_language');?></button>
</div>
</div>
<?php echo form_close();?>
</div>
</div>
<!----LANGUAGE ADDING FORM ENDS-->
</div>
</div>
</div>
</div>

Unable to post value from bootstrap-wysiwyg text editor in codeigniter

I am using bootstrap-wysiwyg text editor in my form, and I am not able to post value in controller
View :
<form id="demo-form2" action="<?php echo base_url();?>admin/post/add" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="middle-name" class="control-label col-md-3 col-sm-3 col-xs-12">Post Details<span style="color:red"> <?php echo form_error('details'); ?></span></label>
<div class="col-md-8 col-sm-8 col-xs-12">
<div id="alerts"></div>
<div class="btn-toolbar editor" data-role="editor-toolbar" data-target="#editor">
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" title="Font"><i class="fa fa-font"></i><b class="caret"></b></a>
<ul class="dropdown-menu">
</ul>
</div>
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" title="Font Size"><i class="fa fa-text-height"></i> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a data-edit="fontSize 5">
<p style="font-size:17px">Huge</p>
</a>
</li>
<li>
<a data-edit="fontSize 3">
<p style="font-size:14px">Normal</p>
</a>
</li>
<li>
<a data-edit="fontSize 1">
<p style="font-size:11px">Small</p>
</a>
</li>
</ul>
</div>
</div>
<div id="editor" class="editor-wrapper"></div>
<textarea id="descr" name="descr" style="display:none;"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-md-8 col-sm-8 col-xs-12 col-md-offset-3"> <button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
And my controller
print_r($_POST); exit;
On searching, I have founded answers like
Solution for this issue
But I don't know how to implement this in my condition. I am getting all the other values expect value in text-area.
Thanks in advance
This will get the editor contents and replace the value of editor_contents on the submit.
<form name="your_form" method="post" onSubmit="document.your_form.editor_contents.value = $('#editor').html()">
<textarea name="editor_contents" style="display:none;"></textarea>
<input type="submit" name="submit">
</form>
And you can access it on PHP like $_POST['editor_contents']
This like passing your data on hidden fields.
Try this
<script type="text/javascript">
$(document).on('submit','#demo-form2',function(){
var editor = CKEDITOR.instances['descr'];
document.getElementById('descr').value = editor.getData();
})
</script>

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.

How to display hidden data of one div to another div?

I am working on a project where I came across where when I click plus sign the data will hide and the appear in the div next to it.
here is the code:
<fieldset class="col-md-4" >
<legend>Services</legend>
<div class="col-md-12" >
<?php
$id = 0;
foreach ($servicesname as $val) {
$id++;
?>
<div class="col-md-12" style="font-size: 16px;" id="itemservices<?php echo $id ?>">
<span style="float:left;" ><?php echo $val[0]['servicename']; ?></span>
<a style="float:right;" href onclick="return addSrvToCart('itemservices<?php echo $id ?>')" >
<strong>&#8377 <?php echo $val[0]['amount']; ?></strong>
<span class="glyphicon glyphicon-plus-sign" id="id_<?php echo $id; ?>"></span>
</a>
</div>
<?php } ?>
</div>
</fieldset>
and the code for next div:
<fieldset class="col-md-4" >
<legend>Cart</legend>
<div style="list-style:none;" class="no-left-padding" id="cart">
<div class="col-md-12" >
</div>
</div>
<div class="col-sm-12 no-right-padding" style="background-color:#f3f0f0; padding-top:6px; border:1px solid#ccc">
<label class="pull-right">/*what should i write here to show the sum */: ₨ </label>
</div>
<button style="margin-top:10px;" class="btn btn-primary btn-sm pull-right" onclick="bookNowAfterFilter()">Book Now</button>
</fieldset>
And This the Jquery code:
<script>
function addSrvToCart(elem){
alert($('#' + elem).html());
$('#' + elem).hide();
//return false;
//what should i write here the show that hidden div
document.getElementById('summery);
return false;
}
</script>
This is the picture and I want to display the data in the Cart div and show the amount
You need to change in both HTML and Script to achieve the result
Try like this
HTML
<fieldset class="col-md-4" >
<legend>Services</legend>
<div class="col-md-12" >
<?php
$id = 0;
foreach ($servicesname as $val) {
$id++;
?>
<div class="col-md-12" style="font-size: 16px;" id="itemservices<?php echo $id ?>">
<span style="float:left;" ><?php echo $val[0]['servicename']; ?></span>
<a style="float:right;" onclick=" addSrvToCart('itemservices<?php echo $id ?>')" >
&#8377<strong> <?php echo $val[0]['amount']; ?></strong>
<span class="glyphicon glyphicon-plus-sign" id="id_<?php echo $id; ?>"></span>
</a>
</div>
<?php } ?>
</div>
</fieldset>
and the code for next div:
<fieldset class="col-md-4" >
<legend>Cart</legend>
<div style="list-style:none;" class="no-left-padding">
<div class="col-md-12" id="cart" >
</div>
</div>
<div class="col-sm-12 no-right-padding pull-right" style="background-color:#f3f0f0; padding-top:6px; border:1px solid#ccc">
Total: ₨ <label class="" id="sumAmount">0</label>
</div>
<button style="margin-top:10px;" class="btn btn-primary btn-sm pull-right" onclick="bookNowAfterFilter()">Book Now</button>
</fieldset>
Script:
function addSrvToCart(elem){
var div=$('#' + elem);
div.hide();
$('#cart').append(div.html());
var total = parseInt(div.find('strong').html()) + parseInt($('#sumAmount').html());
$('#sumAmount').html(total);
}
It will produce output as
I think it will help you.

Categories