AngularJS compare objects of scope outside ng-repeat - php

Below code of $scope.Deelnemers.
Example: I have two Users / Deelnemers ID 1 and 2 via API from Mysql-db.
App.js
getDeelnemers(){
$http({
method: 'POST',
url: 'api.php?users=users',
data: {}
}).then(function successCallback(response) {
$scope.Deelnemers = response.data;
console.log('Deelnemers: ',$scope.Deelnemers);
}, function errorCallback(response) {
alert('Fout met ophalen sponsors!');
});
};
<div class="row" ng-repeat="Deelnemer in Deelnemers">
<div class="col-md-1">
<input name="id" class="form-control input-sm" value="{{Deelnemer.deelnemer_id}}" type="text" disabled>
</div>
<div class="col-md-3">
<input name="names" class="form-control input-sm" value="{{Deelnemer.naam}}" type="text" disabled>
</div>
<div class="col-md-1">
<input name="groupsnr" class="form-control" ng-model="Deelnemer.groupnr" ng-change="saveAssingDeelnemerGroupnr(Deelnemer.groupnr,Deelnemer.deelnemer_id)"></input>
</div>
<div class="col-md-3" ng-init="getSponsorName(Deelnemer.sponsor)">
{{ SponsorName }}
</div>
</div>
I would like to show the Sponsorname with a getter getSponsorName(Deelnemer.sponsor).
For User ID 1, Deelnemer.sponsor = 987 and for User ID 2, Deelnemer.sponsor = 789
$scope.getSponsorName = function(SponsorId) {
if(SponsorId == 987) {
$scope.SponsorName = "Foo";
}
if(SponsorId == 789) {
$scope.SponsorName = "Bar";
}
}
Output of {{ SponsorName }} is for both users "Bar" while Deelnemer.sponsor for both is different?
I guess it's something simple what I'm doing wrong but I don't see/know it.
Thanks in advance.

You are getting the same value because you are using the same model for all rows,Try the following
html
<div class="col-md-3" ng-init="getSponsorName(Deelnemer)">
{{ Deelnemer.SponsorName }}
</div>
js
$scope.getSponsorName = function(Deelnemer) {
if(Deelnemer.SponsorId == 987) {
Deelnemer.SponsorName = "Foo";
}
if(Deelnemer.SponsorId == 789) {
Deelnemer.SponsorName = "Bar";
}
}

Related

Error of "Invalid argument supplied for foreach()" in Laravel

This is my blade view where i am taking values of total closing report and total deposit. if it differs, automatically difference is being calculated and displayed. On the basis of difference, below details need to be added for the difference amount and stored in cashoutexpense.
For example - Total Closing Report is 200 , Total Deposit is 100 then details need to be provided for difference amount. i.e 100. In this case, suppose user has given input for expense amount as 50 in one textbox and 50 in another by adding another row.
<div class="form-group row">
<div class="col-12">
<label>Total Closing Report</label>
<input class="form-control" v-model="form.closing_report_total" #change="calculate" type="number" required name="closing_report_total" placeholder="Enter Closing Report Total">
</div>
</div>
<div class="form-group row">
<div class="col-12">
<label>Total Deposit</label>
<input class="form-control" type="number" v-model="form.total_deposit" #change="calculate" required name="total_deposit" placeholder="Enter Total Deposit">
</div>
</div>
<div class="form-group row">
<div class="col-12">
<label>Difference</label>
<input class="form-control" type="number" v-model="form.difference" name="difference" placeholder="Enter Difference" readonly>
</div>
</div>
<div class="form-group row" v-if="form.difference != 0" v-for="(comment, k) in form.cashoutexpenses" :key="k">
<div class="col-4">
<input type="text" class="flatpickr form-control" v-model="comment.expense_date" required name="expense_date" placeholder="Click here to choose Date">
</div>
<div class="col-4">
<input class="form-control" type="number" v-model="comment.amount" required name="amount" placeholder="Enter Expense Amount" #change="calculate_error">
</div>
<div class="col-4">
<input class="form-control" type="text" v-model="comment.comment" required name="comment" placeholder="Enter Expense Comments">
</div>
<div class="col-4">
<button class="btn btn-sm btn-danger" type="button" #click="removeRow(k)">Remove</button>
</div>
</div>
<div class="form-group row" v-if="form.left > 0">
<div class="col-12">
<input class="btn btn-primary form-control" type="button" value="Add Row" #click="addRow()">
</div>
</div>
Below is my script code for the same.
<script>
var app = new Vue({
el: '#app',
mounted: function() {
},
computed: {
difference: function() {
return this.form.difference = this.form.closing_report_total - this.form.total_deposit;
}
},
data: {
form: {
closing_report_total : 0.00,
total_deposit: 0.00,
difference: 0.00,
left: 0.00,
comments: '',
cashoutexpenses: [],
buffer: []
},
},
methods: {
addRow() {
this.form.cashoutexpenses.push({
date: '',
amount: '',
comment: '',
});
this.form.buffer = JSON.parse(JSON.stringify(this.form.cashoutexpenses));
},
removeRow(index) {
this.form.cashoutexpenses.splice(index, 1);
this.form.buffer = JSON.parse(JSON.stringify(this.form.cashoutexpenses));
},
calculate: function() {
this.form.difference = this.form.closing_report_total - this.form.total_deposit;
this.form.cashoutexpenses = [];
this.form.buffer = JSON.parse(JSON.stringify(this.form.cashoutexpenses));
if(this.form.difference != 0) {
this.addRow();
}
},
calculate_error: function() {
this.form.left = this.form.difference - this.form.cashoutexpenses.reduce((a,b)=> (a + (parseInt(b['amount'])||0)),0);
if(this.form.left<0) {
alert("Sum of expenses should not exceed total amount");
for(var i=0; i<this.form.cashoutexpenses.length;i++) {
if(this.form.cashoutexpenses[i].amount!=this.form.buffer[i].amount) {
this.form.buffer[i].amount = 0;
this.form.cashoutexpenses[i].amount=this.form.difference - this.form.buffer.reduce((a,b)=> (a + (parseInt(b['amount'])||0)),0);
}
}
}
else if(this.form.left>0) {
alert("Please add "+this.form.left+" more");
}
this.form.buffer = JSON.parse(JSON.stringify(this.form.cashoutexpenses));
},
formSubmit: function(e) {
e.preventDefault();
let currentObj = this;
// let data = new FormData();
let formData = new FormData()
formData.append('closing_report_total', this.form.closing_report_total);
formData.append('total_deposit', this.form.total_deposit);
formData.append('difference', this.form.difference);
formData.append('form.cashoutexpenses', this.form.cashoutexpenses);
let config = { headers: { 'Content-Type': 'multipart/form-data' } }
axios.post('/cashoutdetails/store', formData ,config)
.then(response => {
//console.log(formData);
//alert('data saved');
//window.location.href = "{{ route('cashoutdetails.index')}}";
})
.catch(function (error) {
alert('Error');
});
}
}
})
</script>
if i check for the same in vue plugin of mozilla firefox, correct data is being displayed which is as follows --
cashoutexpenses:Array[2]
0:Object
amount:"50"
comment:"test2"
date:""
expense_date:"2021-10-10"
1:Object
amount:"50"
comment:"test3"
date:""
expense_date:"2021-10-12"
Now in my controller , i am fetching the data which is as below -
$comments = $request->form_cashoutexpenses;
//return $comments;
foreach($comments as $c) {
return $c;
$cashout_comments = new CashOutExpenses;
$cashout_comments->cashout_id = $cashout_details->id;
$cashout_comments->expense_date = $c['expense_date'];
$cashout_comments->amount = $c['amount'];
$cashout_comments->explanation = $c['comment'];
$cashout_comments->save();
}
return response()->json([
'message' => 'Details added!',
], 201);
If i return $comments, it gives reply as [object Object],[object Object] otherwise it returns error for foreach.
if i return $request->all(); ... it gives following output -
{"closing_report_total":"200","total_deposit":"100","difference":"100","form.cashoutexpenses":"[object Object]"}
Please help me to save this data in cashout_expense table.
I do not fully understand your code, but I've noticed some potentially problematic parts:
$request->form_cashoutexpenses most likely is not an array, that is why you probably getting this error. You can check it putting dd($comments, gettype($comments)); after declaration of $comments and rerunning page
Having return statement inside foreach loop at the first line seems to be silly, because the code below will never be executed.

How to post an Ajax onClick through a looping input form (Dinamically) from MySql query result

I would like to be suggested on how to solve an Ajax post through a looping input form (Dynamically) from MySql query result.
<?php
// Query Result
foreach ($sql->result() as $row) {
echo '
<div class="media mt-4">
<div class="media-body text-muted text-small">
<input class="d-none" value="'.$row->cY.'" name="post_X" id="post_X">
<input class="d-none" value="'.$row->cZ.'" name="post_Y" id="post_Y">
<div class="input-group">
<input style="background:#fafafa" type="text" name="post_Z" id="post_Z" placeholder="Join conversation here..." class="form-control">
<div class="input-group-append">
<button type="button" onclick="addPost()" class="btn btn-outline-secondary"><i class="fa fa-send"></i></button>
</div>
</div>
</div>
</div>';
}
?>
Ajax script
<script>
function addPost() {
if(!$("#post_Z").val()) {
// An Alert!
} else {
var post_X = $("#post_X").val();
var post_Y = $("#post_Y").val();
var post_Z = $("#post_Z").val();
$.post("reply.php", {
uid: post_X,
cid: post_Y,
txt: post_Z
}, function (data, status) {
// An Alert!
});
};
}
</script>
Thanks alot
give an id for each iteration, and add the id in the addPost event so that the post only retrieves data according to the id that is defined
change the code to be like this
<?php
// Query Result
$uniq = 1;
foreach ($sql->result() as $row) {
echo '
<div class="media mt-4">
<div class="media-body text-muted text-small">
<input class="d-none" value="'.$row->cY.'" name="post_X_'.$uniq.'" id="post_X_'.$uniq.'">
<input class="d-none" value="'.$row->cZ.'" name="post_Y_'.$uniq.'" id="post_Y_'.$uniq.'">
<div class="input-group">
<input style="background:#fafafa" type="text" name="post_Z_'.$uniq.'" id="post_Z_'.$uniq.'" placeholder="Join conversation here..." class="form-control">
<div class="input-group-append">
<button type="button" onclick="addPost('.$uniq.')" class="btn btn-outline-secondary"><i class="fa fa-send"></i></button>
</div>
</div>
</div>
</div>';
$uniq++;
}
?>
and the ajax
<script>
function addPost(id) {
if(!$("#post_Z_"+id).val()) {
// An Alert!
} else {
var post_X = $("#post_X_"+id).val();
var post_Y = $("#post_Y_"+id).val();
var post_Z = $("#post_Z_"+id).val();
$.post("reply.php", {
uid: post_X,
cid: post_Y,
txt: post_Z
}, function (data, status) {
// An Alert!
});
};
}
</script>
may these help

I have patients information in database, now I want to access one's information in another form in Laravel Project

I have patients information in database, now I want to access one's information in another form. When I will input patient's ID the patient name field need to be filled/loaded automatically. I have my Patient model also.
This is the from...
<form method="post" class="" action="" >
#csrf
<div class="input-field col s3">
<input name="patient_id" id="id" type="text" class="validate">
<label class="active" for="id">Patient ID</label>
</div>
<div class="input-field col s9">
<input name="patient_name" id="name" type="text" class="validate">
<label class="active" for="name">Patient Name</label>
</div>
<div class="input-field col s12">
<select name="room">
<option value="" disabled selected>Select Room</option>
<option value="2001">ROOM 2001 - Non AC - 500</option>
<option value="4001">ROOM 4001 - AC -800</option>
<option value="301">CABIN 301 - AC - 1700</option>
</select>
</div>
<div class="input-field col s12 text-center">
<button class="btn waves-effect waves-light" type="submit" name="action">Assign Room</button>
</div>
</form>
You can
create the json object in the blade template, which may be a little messy if special characters are present. Also, i don't see this as a good solution if you have tons of records.
I would use a library, like https://select2.org/, what you'll be looking for is here https://select2.org/data-sources/ajax ... i personally use this one https://semantic-ui.com/modules/search.html#/examples... but i think select2 is more straight.
At the bottom of https://select2.org/data-sources/ajax you can see how an object with the full data can be passed while querying the server.
Since the name is just for searching the id ( I Assume)
You could also adjust your controller so it looks in CONCAT(id,name) so the user can type the id or name and find the patient.
Pass the patient details to the view through the compact and use the values of the patient collection accordingly in the input fields.
controller
public function edit($id){
$patient = Patient::find($id);
return view('patients.edit, compact('patient'))
}
In the view
<input value="{{ old('name') ? old('name') : $patient->name }}" name="name" type="text" class="form-control" required>
<input name="patient_id" onkeydown="getInfo(this)" id="id" type="text" class="validate">
<script type="text/javascript">
function getInfo(input){
var xhr = new XMLHttpRequest();
xhr.open("GET", 'your/url/to/get/info/from/db/'+input.value, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send();
xhr.onload = function() {
var data = JSON.parse(this.responseText);
document.getElementById('name').value = data.name;
document.getElementById('room').innerHTML= '<option value="'+
data.room +'">'+data.room +'</option>';
data.name
}}
you can try this.
Execute a JavaScript when a you Enter patient id in input field:
here is the example -> https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_ev_oninput
HTML
<input name="patient_id" id="id" type="text" class="validate" oninput="myFunction()">
Javascript
function myFunction() {
var p_id = document.getElementById("id").value;
$.ajax({
url: '{{URL::to('get_patient_name')}}'+ '/'+p_id,
type: "get",
success: function (data) {
}
});
}
Now make one route:
Route::get('get_patient_name/{p_id}', 'PatientController#getPatientName'});
In controller get the name of the patient
public function getPatientName($id)
{
return ModelName::where('patient_id',$id)->value('patient_name');
}
and finally, print patient name in the name input field.
in the javascript success function
success: function (data) {
$('#name').val(data);
}
If you want to do it without using jquery, here is vanilla js
dont forget to change request url!
document.querySelector("#id").addEventListener("change", function () {
let xml = new XMLHttpRequest(),
token = document.querySelector("input[name=_token]").value,
id = document.querySelector("#id").value,
name = document.querySelector("#name");
xml.open("get", "get/" + id); // change url
xml.setRequestHeader("X-CSRF-TOKEN", token);
xml.onreadystatechange = function () {
if (xml.readyState === 4) {
var response = JSON.parse(xml.responseText);
if (xml.status === 200 ) {
name.value = response
} else {
console.log('something bad happened');
}
}
};
xml.send()
})
Then in your controller find patient and send back
public function getPatient($id){
$patient = Patient::find($id);
return response()->json($patient->name);
}

foreach function in JSON returning only one row

I'm trying to display more than one row from JSON response, but somehow it is returning only one row each time. Query working well on the server. Code works well if i use it without ajax/json. I'm having headache with this. what am I doing wrong here? Any help would be appreciated.
HTML
<form>
<span id="span_section_row"></span>
<hr>
<div class="row">
<div class="form-group col-lg-6">
<label for="exam_date">Select Date of Exam</label>
<input type="text" class="form-control" id="exam_date" required readonly>
</div>
<div class="form-group col-lg-6">
<label for="exam_time">Enter Exam Time(In Minutes)</label>
<input type="number" class="form-control" id="exam_time" required>
</div>
</div>
</form>
AJAX call:
$(document).on('click', '.schedule', function(){
var exam_id = $(this).attr("id");
var btn_action = 'fetch_single';
$.ajax({
url:'web-services/schedule-exam.php',
method:"POST",
data:{exam_id:exam_id, btn_action:btn_action},
dataType:"json",
success:function(data)
{
$('#setup_exam_modal').modal('show');
$('#span_section_row').html(data.section_row);
}
})
});
PHP:
if($_POST['btn_action'] == 'fetch_single')
{
$exam_type_id = $_POST['exam_id'];
$query = "
SELECT a.*, b.exam_type_name
FROM exam_section a
INNER JOIN exam_type b
ON a.exam_type_id=b.exam_type_id
WHERE a.status = :status
AND a.exam_type_id = :exam_type_id
";
$statement = $conn->prepare($query);
$statement->execute(
array(
':status' => 'active',
':exam_type_id' => $exam_type_id
)
);
$result = $statement->fetchAll();
foreach($result as $row)
{
$output['section_id'] = $row['section_id'];
$output['exam_type_id'] = $row['exam_type_id'];
$output['section_name'] = $row['section_name'];
$output['exam_type_name'] = $row['exam_type_name'];
$output['section_row'] =
'<div class="row">
<div class="form-group col-lg-4">
<label for="select_section"></label>
<p id="select_section">'.$row['section_name'].'</p>
</div>
<div class="form-group col-lg-4">
<label for="no_of_questions">No. of Questions</label>
<input type="number" class="form-control" id="no_of_questions" required>
</div>
<div class="form-group col-lg-4">
<label for="mark_per_question">Mark Per Question</label>
<input type="number" class="form-control" id="mark_per_question" required>
</div>
</div>
';
}
echo json_encode($output);
}
First in the PHP you are overwriting the array each time round the loop so there would only ever have been one occurance passed back to the javascript to process
if($_POST['btn_action'] == 'fetch_single') {
$exam_type_id = $_POST['exam_id'];
$query = "SELECT a.*, b.exam_type_name
FROM exam_section a
INNER JOIN exam_type b ON a.exam_type_id=b.exam_type_id
WHERE a.status = :status
AND a.exam_type_id = :exam_type_id";
$statement = $conn->prepare($query);
$statement->execute(
array( ':status' => 'active',
':exam_type_id' => $exam_type_id)
);
$result = $statement->fetchAll();
foreach($result as $row) {
$htm = '<div class="row">
<div class="form-group col-lg-4">
<label for="select_section"></label>
<p id="select_section">'.$row['section_name'].'
</p>
</div>
<div class="form-group col-lg-4">
<label for="no_of_questions">No. of Questions</label>
<input type="number" class="form-control" id="no_of_questions" required>
</div>
<div class="form-group col-lg-4">
<label for="mark_per_question">Mark Per Question</label>
<input type="number" class="form-control" id="mark_per_question" required>
</div>
</div>';
$output[] = [
'section_id' => $row['section_id'],
'exam_type_id' => $row['exam_type_id'],
'section_name' => $row['section_name'],
'exam_type_name' => $row['exam_type_name'],
'section_row' => $htm
];
}
echo json_encode($output);
}
So now in the javascript you will need to process that array as RASHAN suggested
$(document).on('click', '.schedule', function(){
var exam_id = $(this).attr("id");
var btn_action = 'fetch_single';
$.ajax({
url:'web-services/schedule-exam.php',
method:"POST",
data:{exam_id:exam_id, btn_action:btn_action},
dataType:"json",
success:function(data)
{
$('#setup_exam_modal').modal('show');
//$('#span_section_row').html(data.section_row);
var t="";
$.each(data,function(index,value){
// concatenate all the occurances of the html and place on page
t += value.section_row;
})
$('#span_section_row').html(t);
}
})
});
Now you have one remaining problem that I can see and that is you are generating multiple HTML element all with the same id like here,
<p id="select_section">'.$row['section_name'].'
in multiple sections of your HTML. As I am not familiar with whats going on elsewhere in the code, possibly you dont need these id's at all and can remove them. Or you will have to make them unique on the page, or amend your javascript to select those elements some other way
From your controller you are returning data as array, you need to iterate over your response as
var append="";
$.each(data,function(i,v){
append += v.section_row;
})
$('#span_section_row').html(append);

While inserting Data into MySQL using Ajax and PHP, taking limited data?

While inserting Data into MySQL using Ajax and PHP, taking limited data from rich textarea,Is there any problem?
JQuery Script
$('#adddesc').click(function(e)
{
e.preventDefault();
var txtcategoryname=tinyMCE.get('txtcategoryname').getContent();
var txttitle=$('#txttitle').val();
var selectError1=$("#selectError1").val();
var selectError2=$("#selectError2").val();
var selectError3=$("#selectError3").val();
//var fimage=$("#fimage").val();
//alert($("#selectError2").val().length);
var dataString;
var err;
err=(txttitle!='' && txtcategoryname!='' && $("#selectError1").val()!='0' && $("#selectError2").val()!='0' && $("#selectError3").val()!='0')?'0':'1';
// var dataString1="txttitle="+txttitle+"& description="+txtcategoryname+"& catname="+selectError1+"& tags="+selectError2;
//dataString1="txttitle="+txttitle+"& description="+txtcategoryname+"& catname="+selectError1+"& tags="+selectError2+"& subcat="+selectError3;
// alert(dataString1);
if(err=='0')
{
dataString="txttitle="+txttitle+"& description="+txtcategoryname+"& catname="+selectError1+"& tags="+selectError2+"& subcat="+selectError3;
//alert(dataString);
$.ajax({
type: "POST",
url: "aAddDescription.php",
data: dataString,
cache: true,
beforeSend: function(){ $("#adddesc").val('Adding Des.....');},
success: function(html){
//$("#txtcategoryname").val('');
tinyMCE.get('txtcategoryname').setContent('');
$("#txttitle").val('');
//$("#selectError1").get(0).selectedIndex = 0;
//$("#error").removeClass("alert alert-error");
$("#error").addClass("alert alert-success");
$("#error").html("<span style='color:#cc0000'>Success:</span> Description Added Successfully. ").fadeIn().delay(3000).fadeOut();
}
});
HTML Form script
<form class="form-horizontal" method="POST" action="" enctype="multipart/form-data" autocomplete="off">
<fieldset>
<div class="control-group">
<label class="control-label" for="selectError">Select Cateogry</label>
<div class="controls">
<?php
$result=mysqli_query($db,"SELECT * FROM categories ");
//$count=mysqli_num_rows($result);
$op="<option value='0'>Select Category</option>";
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC))
{
$op.="<option value='".$row['id']."'>".$row['title']."</option>";
}
?>
<select id="selectError1" >
<?php echo $op; ?>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="selectError">Select Sub Cateogry</label>
<div class="controls">
<select id="selectError3">
<option selected="selected" value="0">--Select Sub--</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="focusedInput">Enter Title:: </label>
<div class="controls">
<input class="form-control" type="text" id="txttitle" name="txttitle" value="" placeholder="Enter Title"><span id="user-availability-status"></span> <img src="LoaderIcon.gif" id="loaderIcon" style="display:none;width:20px;height:20px;" />
</div></div>
<div class="control-group">
<textarea rows="10" cols="20" name="content" style="width:100%; height:150px" id="txtcategoryname"></textarea>
</div>
<div class="control-group">
<label class="control-label" for="selectError1">Tags(select All with Press Ctrl)</label>
<div class="controls">
<?php
$result=mysqli_query($db,"SELECT * FROM tags ");
//$count=mysqli_num_rows($result);
$op1='';
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC))
{
$op1.="<option value='".$row['title']."'>".$row['title']."</option>";
}
?>
<select id="selectError2" multiple >
<?php //echo $op1; ?>
</select>
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary" id="adddesc">Save changes</button>
<button class="btn">Cancel</button>
</div>
</fieldset>
</form>
aAddDescription.php
<?php
include("common/db.php");
session_start();
if(isSet($_POST['description']) && isSet($_POST['txttitle']))
{
// username and password sent from Form
$description=$_POST['description'];
$txttitle=mysqli_real_escape_string($db,$_POST['txttitle']);
$catname=mysqli_real_escape_string($db,$_POST['catname']);
$subcat=mysqli_real_escape_string($db,$_POST['subcat']);
$tags=mysqli_real_escape_string($db,$_POST['tags']);
//$fimage=$_FILES['fimage']['name'] ;
$cby=$_SESSION['login_user'];
//$result=mysqli_query($db,"SELECT * FROM categories WHERE title='$categoryname'");
//$count=mysqli_num_rows($result);
//$target_dir = "uploads/";
//$target_file = $target_dir.$_FILES['fimage']['name'];
//move_uploaded_file($_FILES['fimage']['tmp_name'],$target_file);
//$row=mysqli_fetch_array($result,MYSQLI_ASSOC);
// If result matched $myusername and $mypassword, table row must be 1 row
/*if($count>0)
{
echo "0";
}
else
{
mysqli_query($db,"INSERT INTO categories(title) VALUES('".$categoryname."')");
echo "1";
}*/
//date_default_timezone_set('Asia/Delhi');
mysqli_query($db,"INSERT INTO description(title,description,cat_id,tags_id,created,modified,createdby,modifiedby,subcat_id) VALUES('".$txttitle."','".$description."','".$catname."','".$tags."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','".$cby."','".$cby."','".$subcat."')");
$cid=mysqli_insert_id($db);
$cresult=mysqli_query($db,"SELECT * FROM counter WHERE cont_id='$cid'");
$ccount=mysqli_num_rows($cresult);
if($ccount==0)
{
mysqli_query($db,"INSERT INTO counter(cont_id) VALUES(".$cid.")");
}
echo "1";
}
?>
Please help me any thing wrong in this code?...even i changed cache to false also getting same problem. if i type 1000/less or more lines data, always it is taking limited data. Please help me. thanks in Advance
I'd be willing to bet that your text has characters in it that are interfering with the url like "&", "?", "/", "=", etc.
You should encode your text with encodeURIComponent() like this:
var txtcategoryname=encodeURIComponent(tinyMCE.get('txtcategoryname').getContent());
var txttitle=encodeURIComponent($('#txttitle').val());
var selectError1=encodeURIComponent($("#selectError1").val());
var selectError2=encodeURIComponent($("#selectError2").val());
var selectError3=encodeURIComponent($("#selectError3").val());

Categories