Send checked table row value in array - php

I have a table like this:
CheckBox Course Semester Paper Level
[] ABC 1 1 •Expert •normal
[] ABC 1 2 •Expert •normal
[] ABC 1 3 •Expert •normal
[Save]
In the above table checkbox value is paper value. The trouble i am having is that , when i click on save, it runs a parameterised javascript function addpapers($course,$semester) as you can see they are same, but i am not able to send the checkbox value and level value together. a person can choose either expert or normal level for a given paper. I am not able to send them in javascript.
function flagaddpapers(course, semester) {
displayBox = document.getElementById("studentBox");
elements = document.getElementsByName('pids[]');
levelid = document.getElementsByName('radios[]');
data = [];
for (i = 0; i < elements.length; i++) {
if (elements[i].checked) {
data.push('pids[]=' + encodeURIComponent(elements[i].value));
}
}
params = "teacher=" + encodeURIComponent(teacher) + "&course=" + encodeURIComponent(course) + "&semester=" + encodeURIComponent(semester) + "&flag=" + encodeURIComponent(1) + "&" + data.join('&');
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.body.removeChild(document.getElementById('loadMsg'));
result = xmlhttp.responseText;
alert(result);
displayBox.className = "dimBox";
setTimeout(function () {
ajaxstp();
document.body.removeChild(document.getElementById('adBackground'));
document.body.removeChild(document.getElementById('adBox'));
}, 200);
}
}
xmlhttp.open("POST", "tpaper.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(params);
}
This is my html code:
echo "<tr>
<th style='font-size:12px;'><input type='checkbox' id='master_check'
onclick='masterSelect();' style='display:inline-block;cursor:pointer;'></th>
<th style='font-size:12px;'>S.No</th>
<th style='font-size:12px;'>Course</th>
<th style='font-size:12px;'>Semester</th>
<th style='font-size:12px;'>Level</th>
<th style='font-size:12px;'>Paper</th></tr>";
$counter17 = 1;
while($row4 = mysql_fetch_array($q4))
{
$pids = $row4['pid'];
echo "<tr>";
echo "<td><input type='checkbox' name='pids[]' class='persistentChecks'
style='display:inline-block;cursor:pointer;' value=".$pids."></td>";
echo "<td style='text-align:center;font-size:12px;'>".$counter17."</td>";
echo "<td style='text-align:center;font-size:12px;'>".$row4['cname']."</td>";
echo "<td style='text-align:center;font-size:12px;'>".$semester."</td>";
echo "<td style='font-size:12px;'><input type='radio' name='radio[]' id='radio1'
value='1'>Expert</input><input id='radio2' type='radio' name='radio[]'
value='2'>Normal</input></td>";
echo "<td style='text-align:center;font-size:12px;'>".$row4['pname']."</td></tr>";
$counter17 = $counter17 + 1;
}
echo "</table>";
echo "<div style='text-align:left;'><input type='button' class='t_s' value='Add Paper'
onclick='flagaddpapers(".$course.",".$semester."); return false'
id='addpaperBtn'><input type='button' class='t_s' value='Cancel' onclick='closedialog();
return false'></div>";

Try this..
here pval is the paperid and lval is the level value
<script type="text/javascript">
function merge_value(lval,pval)
{
document.getElementById(pval).value=pval + '-' + lval;
}
</script>
<?php
echo "<tr>
<th style='font-size:12px;'><input type='checkbox' id='master_check'
onclick='masterSelect();' style='display:inline-block;cursor:pointer;'></th>
<th style='font-size:12px;'>S.No</th>
<th style='font-size:12px;'>Course</th>
<th style='font-size:12px;'>Semester</th>
<th style='font-size:12px;'>Level</th>
<th style='font-size:12px;'>Paper</th></tr>";
$counter17 = 1;
while($row4 = mysql_fetch_array($q4))
{
$pids = $row4['pid'];
echo "<tr>";
echo "<td><input type='checkbox' name='pids[]' id='".$pids."' class='persistentChecks'
style='display:inline-block;cursor:pointer;' value=".$pids."></td>";
echo "<td style='text-align:center;font-size:12px;'>".$counter17."</td>";
echo "<td style='text-align:center;font-size:12px;'>".$row4['cname']."</td>";
echo "<td style='text-align:center;font-size:12px;'>".$semester."</td>";
echo "<td style='font-size:12px;'><input type='radio' name='radio[]' id='radio1'
value='1' onClick='javascript:merge_value(this.value,".$pids.")'>Expert</input><input id='radio2' type='radio' name='radio[]'
value='2' onClick='javascript:merge_value(this.value,".$pids.")'>Normal</input></td>";
echo "<td style='text-align:center;font-size:12px;'>".$row4['pname']."</td></tr>";
$counter17 = $counter17 + 1;
}
echo "</table>";
echo "<div style='text-align:left;'><input type='button' class='t_s' value='Add Paper'
onclick='flagaddpapers(".$course.",".$semester."); return false'
id='addpaperBtn'><input type='button' class='t_s' value='Cancel' onclick='closedialog();
return false'></div>";
?>

Related

How to add submit button in a form row and print the data on student side

I am creating an online web-based grading system and I am having a difficult time adding a submit button on every row after each grade. So far, my code only allows me to post the grade on the student side of the portal once the first and second quarter grades are complete. I wanted to post the grades every quarter in line with the mandate of the school.
Here is the code that I used so far:
<tr>
<td><?php echo $learnerCount++; ?></td>
<td><?php echo htmlentities($learner->StudLastName); ?>, <?php echo htmlentities($learner->StudFirstName); ?> <?php echo htmlentities($learner->StudMiddleName); ?></td>
<?php
// print out Grades for the selected Quarter
$semGradeCount = 0;
$semesterGrade = 0;
foreach ($learnerGrades as $learnerGrade) {
if ($advising->Semester == 1) {
if ($learnerGrade->Quarter == 1) {
echo "<td >$learnerGrade->Result</td>";
$semGradeCount++;
$semesterGrade += $learnerGrade->Result;
} else if ($learnerGrade->Quarter == 2) {
echo "<td >$learnerGrade->Result</td>";
$semGradeCount++;
$semesterGrade += $learnerGrade->Result;
}
} else if ($advising->Semester == 2) {
if ($learnerGrade->Quarter == 3) {
echo "<td >$learnerGrade->Result</td>";
$semGradeCount++;
$semesterGrade += $learnerGrade->Result;
} else if ($learnerGrade->Quarter == 4) {
echo "<td >$learnerGrade->Result</td>";
$semGradeCount++;
$semesterGrade += $learnerGrade->Result;
}
}
}
if ($semGradeCount != 2) {
for ($i = $semGradeCount + 1; $i <= 2; $i++) {
echo "<td>-</td>";
}
}
if ($semGradeCount == 2) {
$finalGrade = $semesterGrade / 2;
$finalGradeQuery = $dbh->prepare("SELECT * FROM tblgrades WHERE StudentId=:studentid AND AdvisingId=:advisingid AND Quarter=5");
$finalGradeQuery->bindParam(":studentid", $learner->id, PDO::PARAM_STR);
$finalGradeQuery->bindParam(":advisingid", $advising->id, PDO::PARAM_STR);
$finalGradeQuery->execute();
if ($finalGradeQuery->rowCount() == 1) {
$finalGradeRes = $finalGradeQuery->fetch(PDO::FETCH_OBJ);
if ($finalGrade != $finalGradeRes->Result) {
echo "<form method='POST'><input type='hidden' name='gradeId' value='$finalGradeRes->id'></input><input type='hidden' name='finalGrade' value='$finalGrade'></input><td>$finalGrade <button class='btn btn-success btn-sm' type='submit' name='repostFinalGrade' data-bs-toggle='tooltip' data-bs-placement='top' title='Post Updated Final Grade'>Submit</button></td></form>";
} else {
echo "<td>$finalGrade</td>";
}
} else {
echo "<form method='POST'><input type='hidden' name='studentId' value='$learner->id'></input><input type='hidden' name='advisingId' value='$advisingId'></input><input type='hidden' name='finalGrade' value='$finalGrade'></input><td > $finalGrade <button class='btn btn-success btn-sm' type='submit' name='postFinalGrade' data-bs-toggle='tooltip' data-bs-placement='top' title='Post Final Grade'>Submit</button></td></form>";
}
if ($finalGrade >= 75) {
echo "<td><b>PASSED</b></td>";
} else echo "<td><b>FAILED</b></td>";
} else {
echo "<td>-</td>";
echo "<td>-</td>";
}
?>
</tr>

Check all / uncheck all Checkbox in looping statement

i have a problem with my program. Here's my snippet code.
Here's the Javascript/Jquery code.
<script language='javascript'>
///SELECTING CHECKBOXES////
$(function(){
// add multiple select / deselect functionality
$("#selectall").click(function () {
$('.case').attr('checked', this.checked);
});
// if all checkbox are selected, check the selectall checkbox
// and viceversa
$(".case").click(function(){
if($(".case").length == $(".case:checked").length) {
$("#selectall").attr("checked", "checked");
} else {
$("#selectall").removeAttr("checked");
}
});
});
</script>
And here's the code where i will integrate that javascript.
<h2>Quotation ID</h2>
<?php
$select_orders = mysql_query ("SELECT * FROM tblorder WHERE project_id = '$project_id' GROUP BY quotation_id") OR DIE (mysql_error());
while ($row2=mysql_fetch_array($select_orders)){
$quote_id = $row2['quotation_id'];
?>
<h3 class="expand"><?php echo $quote_id; ?></h3>
<div class="collapse">
<table align='center' border='1' class='display'>
<thead>
<th><input type='checkbox' onclick='checkall()' id='selectall'/></th>
<th>Product Type</th>
<th width='20px'>Product type code</th>
<th width='20px'>Quantity</th>
<th>Width</th>
<th>Height</th>
<th>Total Sub.</th>
</thead>
<tbody>
<?php
$tots_tots = 0;
$tots_subs = 0;
$select_orders2 = mysql_query ("SELECT * FROM tblorder WHERE project_id = '$project_id' AND quotation_id = '$quote_id'") OR DIE (mysql_error());
while ($row3=mysql_fetch_array($select_orders2)){
$idd = $row3['id'];
$project_id2 = $row3['project_id'];
$order_id = $row3['quotation_id'];
$prod_type = $row3['prod_type'];
$prod_type_code = $row3['prod_type_code'];
$qty = $row3['qty'];
$width = $row3['width'];
$height = $row3['height'];
$tot_sub = $row3['total_subs'];
$tots_subs += $tot_sub;
echo "<tr bgcolor='".$colors[$c++ % 2]."' align='center'>";
echo "<td>
<input type='hidden' name='project_name' value='$project_name'>
<input type='checkbox' name='check_ptc[]' value='$prod_type_code' style='display:none;' checked>
<input type='checkbox' class='case' name='checkbox[]' value='".$idd."'></td>";
echo "
<input type='hidden' name='project_id[]' value='$project_id2'>
</td>";
echo "<td>".$prod_type."
<input type='hidden' name='quotation_id[]' value='$order_id'>
<input type='hidden' name='prod_type[]' value='$prod_type'>
</td>";
echo "<td>".$prod_type_code."
<input type='hidden' name='prod_type_code[]' value='$prod_type_code'>
</td>";
echo "<td>".$qty."</td>";
echo "<td>".$width."</td>";
echo "<td>".$height."</td>";
echo "<td>".$tot_sub."</td>";
echo "</tr>";
}
echo "<tr>";
echo "<td></td><td></td><td></td><td></td><td></td>
<td>
<strong><b>Total:</b></strong>";
echo "</td>";
echo "<td>
<font color='#900'><u><b>$tots_subs</b></u></font>
</td>";
echo "</tr>";
?>
</tbody>
</table>
</div>
<?php
}
?>
Since the table is in the loop. the problem is when the first table appear. and click the first header checkbox it will check all the checkbox in other table. which i dont want to happen. the one i am looking for is if there is a way i can also iterate the ID of the checkbox and its class. or there's any other way to do what i want to happen.
As you can see. those 3 tables have there own checkbox header where i want to be the check all inside there tables. what would be your smart idea how can i do that.
Thanks in advance..
You can do it like this.
$('.allcb').on('click', function(){
var childClass = $(this).attr('data-child');
$('.'+childClass+'').prop('checked', this.checked);
});
FIDDLE
UPDATE
Just apply the class allcb to the main check-boxes and to the child check-boxes apply the class named as chk. This should fit your needs. Here is the updated
FIDDLE
use .prop
$(function () {
var $cases = $('.case');
// add multiple select / deselect functionality
var $all = $("#selectall").click(function () {
$$cases.prop('checked', this.checked);
});
// if all checkbox are selected, check the selectall checkbox
// and viceversa
$cases.click(function () {
$all.prop("checked", $cases.filter(":not(:checked)").length) != 0);
});
});
try this php code instead script
//check-all / uncheck-all checkbox.
<a onclick="$(this).parent().find(':checkbox').attr('checked', true);"><?php echo $text_select_all; ?></a>/<a onclick="$(this).parent().find(':checkbox').attr('checked', false);"><?php echo $text_unselect_all; ?></a>

Show alert with the content of a Database selection

I am very new to JavaScript what is related to it.
I have a set of dynamic rows and corresponding columns to those rows. In one column I have a button. When I click on it, it displays the results of a select query in another page based on the Posted Competence_ID.
The query works fine and I get correct results when I click on the button. However, what I would like to do now, is to display that message in an alert when the button is clicked and stay on the same page rather than opening a new tab..
Here is the relevant HTML code that shows the table I use:
echo "<table border='1' id='mycompstable' class='sortablee' cellpadding='0' cellspacing='0'>";
echo "<tr><th>ID</th><th>Competence Group</th><th>Competence Class</th><th>Competence Description</th><th>Own Evaluation</th><th>Manager's evaluation from last year</th><th>Target levels</th><th>Gap</th><th>Action</th><th class='unsortable'>Action ready target </th></tr>";
foreach($descs as $compi){
echo "<tr>";
echo "<td>".$compi['Competence_ID']."</td>";
echo "<td><p style='text-align: center;'>".$compi['Competence_Group']."</p></td>";
if(isset($compi['Competence_class'])){echo "<td>".$compi['Competence_class']."</td>";}else echo "<td><p style='text-align: center;'>-</p></td>";
echo "<td>".$compi['Competence_Description']."</td>";
echo "<td class='evaluation'>";
echo "<select class='ownlevelselect' id='ownlevelselect-.".$compi['Competence_ID']."' name='level-".$compi['Competence_ID']."' >";
if (isset($compi['ownlevel']) && $compi['ownlevel']!= '' && !empty($compi['ownlevel']) && $compi['ownlevel']!= 0) {
echo "<option selected value='".$compi['ownlevel']."' selected='selected'>".$compi['ownlevel']."</option>";
}
echo "<option value='' >--</option>";
echo "<option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option>";
echo "</select>";
echo $compi['ownlevel'];
echo '<a test="'.$compi['Competence_ID'].'" onClick="showLevels('.$compi['Competence_ID'].');" target="_blank" href="'.INDEX.'?categ='.$_GET['categ'].'&action='.$_GET['action'].'&subaction=viewlevels'.'&levels='.$compi['Competence_ID'].'">';
echo '<img class="linkki" src="'.KUVAT.'paivita.gif" alt="'._("tiedot").'" title="'._("Click to view the description of each level?").'"/></a>';
echo "</td>";
Here is the code to retrieve the data:
function fetchlevels($Competence_id){
$this->query="SELECT * FROM levels WHERE comp_id=".$_REQUEST['levels'];
$tulos=$this->suoritaKysely();
return $tulos;
}
And here is the page that I want to show in the message:
$levels=$this->levels;
$comp=$this->compdesc;
echo "Levels explanation for the competence:".$comp['Competence_Description']."<br>";
echo "Level 1 = ".$levels[0]['lvl1'];
echo "<br>"."level 2 = ".$levels[0]['lvl2'];
echo "<br>"."level 3 = ".$levels[0]['lvl3'];
echo "<br>"."level 4 = ".$levels[0]['lvl4'];
echo "<br>"."level 5 = ".$levels[0]['lvl5'];
echo "<br><br>";
echo '<input type="button" value="close" window onclick="window.close();">';
?>
Any kind of help would be very much appreciated
Here is a Ajax simulation in jsfiddle
http://jsfiddle.net/ncubica/Umxjb/
HTML
<i style='display:none' id="loadingPopup">Loading</i>
<table>
<tr>
<td data-id="td1"> row 1</td>
</tr>
<tr>
<td data-id="td2"> row 2</td>
</tr>
<tr>
<td data-id="td3"> row 3</td>
</tr>
</table>
javascript
$("table").on("click", function(event){
var $target = $(event.target);
if($target.is("td")){
var id = $target.attr("data-id");
makeAjax(id);
}
});
//simulating ajax
function makeAjax(id){
//you will have to use ajax an retrieve you json format
//i will simulate ajax only
$("#loadingPopup").show();
var _json = { id : id, value : "some value", description : "some description"};
setTimeout(function(){response(_json)}, 1000);
}
function response(_json){
$("#loadingPopup").hide();
alert(_json.id + " - " + _json.value);
}
CSS
table{font-family:arial; font-size:12px; width:100%}
table tr td{border-bottom:1px solid #CCC; padding:10px;}
Just an example based on the given info!
echo '<a onClick="showLevels('.$compi['Competence_ID'].');">';
echo '<img class="linkki" src="'.KUVAT.'paivita.gif" alt="'._("tiedot").'" title="'._("Click to view the description of each level?").'"/></a>';
Javascript/jQuery/Ajax
function showLevels(comp_id)
{
$.ajax({
type: "GET",
url: "process_file.php?comp_id="+comp_id,
success: function (result) {
alert(result);
}
});
}
process_file.php
<?php
//Your database Config.
$comp_id=$_REQUEST['comp_id'];
$this->query="SELECT * FROM levels WHERE comp_id=".$comp_id;
$tulos=$this->suoritaKysely();
//Proper Output Actions
$levels=$this->levels;
$comp=$this->compdesc;
echo "Levels explanation for the competence:".$comp['Competence_Description']."<br>";
echo "Level 1 = ".$levels[0]['lvl1'];
echo "<br>"."level 2 = ".$levels[0]['lvl2'];
echo "<br>"."level 3 = ".$levels[0]['lvl3'];
echo "<br>"."level 4 = ".$levels[0]['lvl4'];
echo "<br>"."level 5 = ".$levels[0]['lvl5'];
echo "<br><br>";
?>

Set approval for admin with checkbox using php,jquery and ajax

I am working in a project where i want to show only those products to user which are selected by admin from database. Actualy i want to set the approval 1 or 0 in database when admin check or unchecked that checkbox.
jobs.php
$(document).ready(function(){
$('input.check').click(function(){
if($("input.check").is(':checked'))
{
$id = $(this).attr("id");
$.post("handle.php",{action:"checked",id:$id},function(data){
alert("Peoduct is set to display...");
});
}
else
{
alert("unchecked");
$id = $(this).attr("id");
$.post("handle.php",{action:"unchecked",id:$id},function(data){
alert("Peoduct is un-set to display...");
});
}
});
});
<?php
$dbqry = mysql_query("select * from job_category");
echo "<table width='50%', border='2'>
<tr>
<th>Catergory ID</th>
<th>Category Name</th>
<th>Remove</th>
<th>Update</th>
<th>Approval</th>
</tr>";
if($dbqry)
{
while($row = mysql_fetch_array($dbqry))
{
echo "<tr>";
echo "<td align='center'>" . $row['c_id'] . "</td>";
echo "<td align='center'>" . $row['cat_name'] ."</td>";
$cid = $row['c_id'];
$aprv = $row['approval'];
echo "<td align='center'><a href='remove.php?action=cat_remove&cid=$cid'>Remove</a></td>";
echo "<td align='center'>
<a href='Update-form.php?action=cat_update&cid=$cid'>Update</a></td>";
?>
<td align="center">
<input type='checkbox' name='approval' value='approval' id ="<? echo $cid; ?>" class="check"/>
</td>
</tr>
<?
}
echo "</table>";
echo '<br/>';
echo "<a href='add.php?action=cat_add'>Add New Category</a>";
}
else
{
die(mysql_error());
}
?>`
handle.php
`<?php
include 'include/connection.php';
$action = $_POST['action'];
$id = $_POST['id'];
//echo $action;
if($action == "checked")
{
$query = "update job_category set approval=1 where c_id=$id";
$result = mysql_query($query);
if(!$result)
{
echo die(mysql_error());
}
}
else if($action == "unchecked")
{
$query = "update job_category set approval=0 where c_id=$id";
$result = mysql_query($query);
if(!$result)
{
echo die(mysql_error());
}
}
?>`
Its working but when i refresh the page or seletc the URL and press enter then all the checked data appears unchecked even after that it does not change value of approval from 1 to 0 in database, but still it make me confuse about which items are checked or unchecked. Any suggestion will be appreciated.
modify checkbox line to show checked if approval=1 in database... try this
<input type='checkbox' name='approval' value='approval' <?php if($row["approval"]==1){ echo "checked=\"checked\"";}) ?> id ="<? echo $cid; ?>" class="check"/>
html
<input type='checkbox' name='approval' value='approval' <?php echo $row["approval"]?"checked=\"checked\"":'';?> id ="<? echo $cid; ?>" class="check"/>
then add js
$(function(){
$('input[type=checkbox]').each(function(){
if($(this).attr('checked') && $(this).attr('checked')=='checked'){
$(this).attr('checked', true);
}else{
$(this).attr('checked', false);
}
})
})
and
if($("input.check").is(':checked'))
to
if($(this).is(':checked'))

Updating content to the database onclick event

I spent the last 2 days trying to make the following code work.
I have three forms with content in different languages. For each of them there is an Edit button which popup a text editor. What I would like to do is when I click the button "Save and close" the edited content would be updated in the database using javascript (AJAX) and PHP/SQL but in the console it gives me the following error: Uncaught ReferenceError: valueContent is not defined. So here is the code I have so far.
$mvccont .=
"<form action='edit_language/".ID.".raw' method='post' target='pop' class='comparelist' style='clear: both' onsubmit='window.open(\"\", \"pop\", \"width=0,height=0,resizeable,scrollbars\");'>".
"<input type='hidden' name='keyword' value='".$keyword."'>".
"<table style='width:100%; border-collapse: collapse;' >".
"<tr><td width='20%' ><div class='info' style='width:100%; border:none;' >".
substr($keyword, 0, 20)."<a title='".$keyword."'><input type='submit' value='Save' class='BUYN'/></a>".
"<a href='edit_language/".$keyword."/delete'><input type='button' value='Delete' class='NONA'/></a>".
"</div></td>";
foreach($lan as $lang=>$lame) {
$idk = str_replace(" ", "", $keyword).$lang;
$mvccont .=
"<td><div class='number3'".(($red[$keyword][$lang]=='')?" style='background: #fcc;'":"")." style='border:none;' >".
"<input type='hidden' name='touch".$lang.$keyword."'/>".
"<input type='text' id='s".$idk."' name='a".$lang."' value='".htmlentities($lame, ENT_QUOTES, "UTF-8")."' onchange=\"this.style.borderColor='#ff0000'; document.getElementsByName('touch".$lang.$keyword."')[0].value='true'\"/><a onclick='popbox(false, ".$idk.", true); mce();'><input type='button' value='Edit' class='BUYN'/></a>".
"<br />".($red[$keyword][$lang]).
"<script>".
"function falaffel".$idk."(step) {".
"var l".$idk."=document.getElementById('s".$idk."').value;".
"if(step==1) {".
"return '<textarea>'+l".$idk."+'</textarea><input type=\"button\" value=\"Save & close\" class=\"NONA\" onclick=\"'+\"document.getElementById('s".$idk."').value=tinyMCE.activeEditor.getContent(); ".$idk."=falaffel".$idk."(1); popboxremove(); document.getElementById('s".$idk."').style.borderColor='#ff0000'; updateValue(); document.getElementsByName('touch".$lang.$keyword."')[0].value='true' \"+'\">';".
"}".
"return l".$idk.";".
"}".
"var ".$idk." = falaffel".$idk."(1); ".
"</script>".
"</div></td>";
}
$mvccont .=
"</tr></table></form>";
Then here is the AJAX code:
function updateValue(){
var ajaxRequest = getXmlHttpRequestObject();
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var valueContent = document.getElementsByTagName("input");
}
}
ajaxRequest.open("POST", "comp/update_lang.php", true);
ajaxRequest.send(valueContent);
}
And finally the PHP code:
<?php
foreach(array(1=>"en", 2=>"it", 3=>"pl") as $id=>$lang) {
if($_POST["touch".$id.$_POST["keyword"]]=="true") {
$sql = "UPDATE translat SET value='".mysql_real_escape_string($_POST["a".$id])."', date=".NOWTIME." WHERE lang=".$id." AND keyword='".urldecode($_POST["keyword"])."'";
$insert = $db->query($sql);
$insert->execute();
#unlink(TEMP."lang_".$lang.".cache");
}
}
$mvccont .=
"<script>".
"window.close();".
"</script>";
die($mvccont);
?>
Thank you so much for your help.

Categories