this is my modal
<div class="modal fade bs-example-modal-lg" id="exampleModal<?php echo $row['t_id'] ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel<?php echo $row['t_id'] ?>">
<div class="modal-dialog modal-lg" role="document">
<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="exampleModalLabel">Termin Ansicht <font color="red">ID</font>: <b><?php echo $row['t_id'] ?></b> <font color="red">Call Agent</font>: <b><?php echo $row['username'] ?></b> <font color="red">Call Datum</font>: <b><?php echo date("d.m.y" , strtotime($row['datum'])) ?></b></h4>
</div>
<div class="modal-body">
<form>
<div class="row">
<div class="col-sm-3">
<input type="text" id="username" value="<?php echo $row['username']; ?>" class="form-control">
</div>
<div class="col-sm-3">
<input type="text" id="t_id" value="<?php echo $row['t_id']; ?>" class="form-control">
</div>
</div>
<br>
<div class="row">
<label class="col-sm-1 control-label">Anrede</label>
<div class="col-sm-2">
<input type="text" id="anrede<?php echo $row['t_id']; ?>" value="<?php echo $row['anrede']; ?>" class="form-control">
</div>
<label class="col-sm-1 control-label">Vorname</label>
<div class="col-sm-3">
<input type="text" id="vorname<?php echo $row['t_id']; ?>" value="<?php echo $row['vorname']; ?>" class="form-control" onselectstart="return false" onpaste="return false;" onCopy="return false" onCut="return false" onDrag="return false" onDrop="return false">
</div>
<label class="col-sm-1 control-label">Nachname</label>
<div class="col-sm-3">
<input type="text" id="nachname<?php echo $row['t_id']; ?>" value="<?php echo $row['nachname']; ?>" class="form-control" onselectstart="return false" onpaste="return false;" onCopy="return false" onCut="return false" onDrag="return false" onDrop="return false">
</div>
</div>
<br>
<div class="row">
<label class="col-sm-1 control-label">Strasse</label>
<div class="col-sm-3">
<input type="text" id="strasse<?php echo $row['t_id']; ?>" value="<?php echo $row['strasse']; ?>" class="form-control">
</div>
<label class="col-sm-1 control-label">PLZ</label>
<div class="col-sm-3">
<input type="text" id="plz<?php echo $row['t_id']; ?>" value="<?php echo $row['plz']; ?>" class="form-control">
</div>
<label class="col-sm-1 control-label">Ort</label>
<div class="col-sm-2">
<input type="text" id="ort<?php echo $row['t_id']; ?>" value="<?php echo $row['ort']; ?>" class="form-control">
</div>
</div>
<br>
<div class="row">
<label class="col-sm-1 control-label">Krankenkasse</label>
<div class="col-sm-3">
<input type="text" id="krankenkasse<?php echo $row['t_id']; ?>" value="<?php echo $row['krankenkasse']; ?>" class="form-control">
</div>
<label class="col-sm-1 control-label">Seit</label>
<div class="col-sm-3">
<input type="text" id="seit<?php echo $row['t_id']; ?>" value="<?php echo $row['seit']; ?>" class="form-control">
</div>
<label class="col-sm-1 control-label">Personen</label>
<div class="col-sm-1">
<input type="text" id="personen<?php echo $row['t_id']; ?>" value="<?php echo $row['personen']; ?>" class="form-control">
</div>
</div>
<br>
<div class="row">
<label class="col-sm-1 control-label">Telefon</label>
<div class="col-sm-2">
<input type="text" id="telefon<?php echo $row['t_id']; ?>" value="<?php echo $row['telefon']; ?>" class="form-control">
</div>
<label class="col-sm-1 control-label">Termin</label>
<div class="col-sm-2">
<input type="date" id="termin<?php echo $row['t_id']; ?>" value="<?php echo $row['termin']; ?>" class="form-control">
</div>
<label class="col-sm-1 control-label">Uhrzeit</label>
<div class="col-sm-2">
<input type="text" id="time<?php echo $row['t_id']; ?>" value="<?php echo date("H:i", strtotime($row['time'])) ?>" class="form-control">
</div>
<div class="col-sm-2">
<select class="form-control" id="vermittler<?php echo $row['t_id']; ?>" value='<?php echo $row['vermittler'];?>'>
<option ><?php echo $row['vermittler'];?></option>
<?php
$result1 = ("SELECT * FROM users where type='berater'") or mysql_error();
$ilaz=mysql_query($result1);
while($rowa = mysql_fetch_array($ilaz)){
?>
<option id="berater" value = "<?php echo $rowa['username']; ?>" >
<?php echo $rowa['username']; ?>
</option>
<?php
}
?>
</select>
</div>
</div>
<br>
<div class="row">
<label for="ccomment" class="control-label col-lg-2">Bemerkung</label>
<div class="col-lg-4">
<textarea class="form-control " id="coment<?php echo $row['t_id']; ?>" required><?php echo $row['coment']; ?></textarea>
</div>
<label for="ccomment" class="control-label col-lg-1">Feedback</label>
<div class="col-lg-4">
<textarea class="form-control " id="feedback<?php echo $row['t_id']; ?>" ></textarea>
</div>
</div>
<br>
<div class="row">
<?php
$bfeedback = ("select id, user, feedback_b, datum from b_feedback where id='". (int)$_GET['t_id']."' order by datum desc" ) or mysql_error();
$bresult = mysql_query($bfeedback);
if($bfeedback === FALSE) {
die(mysql_error()); // TODO: better error handling
}
while($beraterfeedback = mysql_fetch_array($bresult)){
?>
<label for="b_feedback" class="control-label col-lg-2"><?php #echo $beraterfeedback['user'] ?><?php #echo $beraterfeedback['datum'] ?></label>
<td><font color="red"><?php echo $beraterfeedback['user'] ?></font></td>
<td><?php echo $beraterfeedback['datum'] ?></td>
<td><?php echo $beraterfeedback['feedback_b'] ?></td><br> <hr>
<?php
}
?>
</div>
<br>
<div class="row">
<div class="col-sm-20">
<?php
$iAstatus = explode(",",$row['Astatus']);
foreach($arrAstatus as $aAstatus)
{
if(in_array($aAstatus,$iAstatus))
echo "<label class='col-sm-1 control-label'><input type='checkbox' class='s' value='".$aAstatus."' checked> .$aAstatus. </label>";
else
echo "<label class='col-sm-1 control-label'><input type='checkbox' class='s' value='".$aAstatus."'> .$aAstatus.</label>" ;
}
?>
</div>
<div class="col-sm-1">
<input type="text" id="positiv<?php echo $row['t_id']; ?>" value="<?php echo $row['abschluss']; ?>" class="form-control">
</div>
</div>
<br>
<div class="row">
<label class="col-sm-5 control-label"><p style="color:red"><font size="2">Personen Angaben (Namen, Geburtsdatum)?</font></p></label>
<div class="col-sm-5">
<textarea class="form-control " id="personen_angaben<?php echo $row['t_id']; ?>" ><?php echo $row['personen_angaben']; ?></textarea>
</div>
</div>
<br>
<div class="row">
<label class="col-sm-5 control-label"><p style="color:red"><font size="2">Sind Sie (bzw. jemand in Ihrem Haushalt) momentan in ärztliche Behandlung/Therapie(Physio) oder steht Ihnen eine Behandlung bevor?</font></p></label>
<div class="col-sm-5">
<input class="form-control" type="text" id="fr_1<?php echo $row['t_id']; ?>" value="<?php echo $row['fr_1']; ?>" >
</div>
</div>
<br>
<div class="row">
<label class="col-sm-5 control-label"><p style="color:red"><font size="2">Zusatzfrage wenn JA- Dies könnte Auswirkungen auf Ihren Wechsel haben. Deshalb, welcher Art ist denn diese Behandlung?</font></p></label>
<div class="col-sm-5">
<input class="form-control" type="text" id="fr_2<?php echo $row['t_id']; ?>" value="<?php echo $row['fr_2']; ?>">
</div>
</div>
<br>
<div class="row">
<label class="col-sm-5 control-label"><p style="color:red"><font size="2">Nehmen Sie (bzw. jemand in Ihrem Haushalt) regelmässig Medikamente?</font></p></label>
<div class="col-sm-5">
<input class="form-control" type="text" id="z_fr_2<?php echo $row['t_id']; ?>" value="<?php echo $row['z_fr_2']; ?>">
</div>
</div>
<div class="row">
<label class="col-sm-5 control-label"><font size="2"><p style="color:red">Zusatzfrage wenn JA- Was sind das für Medikamente oder für was müssen Sie diese nehmen?</p></font></label>
<div class="col-sm-5">
<input class="form-control" id="fr_3<?php echo $row['t_id']; ?>" value="<?php echo $row['fr_3']; ?>" >
</div>
</div>
<div class="row">
<label class="col-sm-5 control-label"><font size="2"><p style="color:red">Hatten Sie (bzw. jemand an Ihrem Haushalt) in den letzten 10 Jahren eine Operation oder steht eine bevor?</p></font></label>
<div class="col-sm-5">
<input class="form-control" type="text" id="z_fr_3<?php echo $row['t_id']; ?>" value="<?php echo $row['z_fr_3']; ?>">
</div>
</div>
<div class="row">
<label class="col-sm-5 control-label"><font size="2"><p style="color:red">Was für eine Operation wann /ist das?</p></font></label>
<div class="col-sm-5">
<input class="form-control" type="text" id="fr_4<?php echo $row['t_id']; ?>" value="<?php echo $row['fr_4']; ?>" >
</div>
</div>
<div class="row">
<label class="col-sm-5 control-label"><font size="2"><p style="color:red">Wenn die Operation in der Vergangenheit war: beziehen Sie nun eine IV-Rente oder ist dies folgenlos geheilt?</p></font></label>
<div class="col-sm-5">
<input class="form-control" type="text" id="z_fr_4<?php echo $row['t_id']; ?>" value="<?php echo $row['z_fr_4']; ?>" >
</div>
</div>
<div class="row">
<label class="col-sm-5 control-label"><font size="2"><p style="color:red">Falls 1 Person krank ist - Können Sie sich vorstellen, einen Teil Ihrer Familie zu versichern?</p></font></label>
<div class="col-sm-5">
<input class="form-control" type="text" id="fr_5<?php echo $row['t_id']; ?>" value="<?php echo $row['fr_5']; ?>" >
</div>
</div>
<div class="row">
<label class="col-sm-5 control-label"><font size="2">Status</font></label>
<div class="col-sm-5">
<input class="form-control" type="text" id="fr_6<?php echo $row['t_id']; ?>" value="<?php echo $row['status']; ?>">
</div>
</div>
<div class="row">
<label class="col-sm-4 control-label"> </label>
<div class="col-sm-3">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" onclick="updatedata('<?php echo $row['t_id'] ?>')" data-dismiss="modal" class="btn btn-primary">Update</button>
</div>
</div>
and this jquery ajax
function updatedata(str){
var t_id = str;
var anrede = $('#anrede'+str).val();
var vorname = $('#vorname'+str).val();
var nachname = $('#nachname'+str).val();
var strasse = $('#strasse'+str).val();
var plz = $('#plz'+str).val();
var ort = $('#ort'+str).val();
var krankenkasse = $('#krankenkasse'+str).val();
var seit = $('#seit'+str).val();
var personen = $('#personen'+str).val();
var telefon = $('#telefon'+str).val();
var termin = $('#termin'+str).val();
var time = $('#time'+str).val();
var vermittler = $('#vermittler'+str).val();
var coment = $('#coment'+str).val();
var feedback = $('#feedback'+str).val();
var s = new Array();
$("input:checked").each(function() {
s.push($(this).val());
});
var positiv = $('#positiv'+str).val();
var personen_angaben = $('#personen_angaben'+str).val();
var fr_1 = $('#fr_1'+str).val();
var fr_2 = $('#fr_2'+str).val();
var z_fr_2 = $('#z_fr_2'+str).val();
var fr_3 = $('#fr_3'+str).val();
var z_fr_3 = $('#z_fr_3'+str).val();
var fr_4 = $('#fr_4'+str).val();
var z_fr_4 = $('#z_fr_4'+str).val();
var fr_5 = $('#fr_5'+str).val();
var fr_6 = $('#fr_6'+str).val();
var datas="anrede="+anrede+"&vorname="+vorname+"&nachname="+nachname+"&strasse="+strasse+"&plz="+plz+"&ort="+ort+"&krankenkasse="+krankenkasse+"&seit="+seit+"&personen="+personen+"&telefon="+telefon+"&termin="+termin+"&time="+time+"&vermittler="+vermittler+"&coment="+coment+"&feedback="+feedback+"&s[]="+s+"&positiv="+positiv+"&personen_angaben="+personen_angaben+"&fr_1="+fr_1+"&fr_2="+fr_2+"&z_fr_2="+z_fr_2+"&fr_3="+fr_3+"&z_fr_3="+z_fr_3+"&fr_4="+fr_4+"&z_fr_4="+z_fr_4+"&fr_5="+fr_5+"&fr_6="+fr_6;
alert(datas);
$.ajax({
type: "POST",
url: "updatedata.php?t_id="+t_id,
data: datas,
cache: false
}).done(function( data ) {
$('#info').html(data);
viewdata();
});
}
and this the php array
$arrAstatus = array("Wollte k T","Kunde Ni err.","St .Gef","N.Zuhaus","Offen","Negativ","MJV","Behan.","Abgesagt","Positiv");
Now when i submit the form it update all unchecked checkboxes.
how can i do that it update only checked checkboxes and after refresh to show me it checked
Problems:
you are creating your checkbox Ids as an array syntax s[]. I believe you are confusing it with the name attribute. Change this: id='s[]' to this: name='s[]'
<font> is no longer supported. Also, the opening and closing tags of that element is not correct.
where is your ajax? where's your form? where's your submit button? Without this info, you leave us to assume this is a form, and that your jquery function gets triggered when the form is submitted. If thats the case, then you need your actionattribute with the URL that AJAX will use to send the request.
Summary:
Please be more descriptive, show your HTML, your PHP, jQuery properly so that we can best help you. In order to solve your problem you need to send an AJAX request. Find out how to do that, implement that in your code, and then we can continue from there.
It seems you need help urgently with this. The main problem I see is that you are missing the name attribute in your form elements. You need to use name attributes so that when you gather the data in jQuery you can use the .serialize() function. I will sort of redo your code in a way that I think you have it working. I will delete all that bootstrap stuff and the non-related code so that you can see what I am doing:
I am assuming your data is coming from your database. I will use an array called $data to mimic that result set:
//your database data
$data = array(
array(
"t_id" => 1,
"username" => "john",
"Astatus" => "Wollte k T,Kunde Ni err.,N.Zuhaus"
)
);
//your comparison data
$arrAstatus = array("Wollte k T", "Kunde Ni err.", "St .Gef", "N.Zuhaus", "Offen", "Negativ", "MJV", "Behan.", "Abgesagt", "Positiv");
Next, I assume you iterate through each result as $row and create your forms. I removed your classes/ids because we do not need them for this purpose. Instead, I placed the needed name attributes in your inputs:
<?php foreach ($data as $row) { ?>
<form>
<input type="text" name="username" value="<?php echo $row['username']; ?>" class="form-control">
<input type="text" name="t_id" value="<?php echo $row['t_id']; ?>" class="form-control">
<?php
$iAstatus = explode(",", $row['Astatus']);
foreach ($arrAstatus as $aAstatus) {
if (in_array($aAstatus, $iAstatus))
echo "<label><input type='checkbox' name='s[]' value='$aAstatus' checked>$aAstatus</label><br>";
else
echo "<label><input type='checkbox' name='s[]' value='$aAstatus'>$aAstatus</label><br>";
}
?>
<input type="submit">
</form>
<?php } ?>
Lastly, your jQuery should be triggered when the form is submitted using the .submit() function. Once submitted, use .serialize() to obtain all inputs with the name attributes and send it through AJAX:
$('form').submit(function () {
var datas = $(this).serialize();
$.ajax({
type: "POST",
url: "submit.php",
data: datas,
cache: false
}).done(function (data) {
console.log(data);
});
return false;
});
Hope this helps.
Related
I have a page where I call a form, receiving reports from users that sometimes it just doesn't submit properly. Not sure why. Any ideas?
Users have been reporting this in various browsers, so it's been especially difficult to track down. Chrome, IE, Edge, Safari, etc. have all reported it, but sometimes it just works.
What the form is supposed to do is take the entered data, then email it to a specific email address.
Magento Block:
<div class="page-title">
<h1>Program</h1>
</div>
<img class="textwrap-right" src="{{media url="wysiwyg/cfi_rebate_badge.png"}}" alt="" />
<div class="std">
<h3 class="ui-helper-clearfix">Sign up below.</h3>
{{widget type="mailform/widget_form" form_template="contacts/cfi.phtml"}}<br />
</div>
This is my contacts/cfi.phtml template:
<?php
$directory = Mage::helper('directory');
$customer = Mage::getSingleton('customer/session')->getCustomer();
$customerAddress = $customer->getAddressById( $customer->getDefaultBilling() );
if($customerAddress->getCountryId() != 'US'){
$customerAddress = Mage::getModel('customer/address');
}
?>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<form action="<?php echo $this->getFormAction() ?>" id="contactForm" method="post" class="scaffold-form">
<div class="fieldset">
<h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h2>
<p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
<ul class="form-list">
<li class="fields">
<div class="field">
<label for="cfirebate:name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Name') ?></label>
<div class="input-box">
<input name="cfirebate[name]" id="cfirebate:name" title="<?php echo Mage::helper('contacts')->__('Name') ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
</div>
</div>
<input type="hidden" name="cfirebate[country]" id="cfirebate:country_id" value="US">
<div class="field">
<label for="cfirebate:address" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Address') ?></label>
<div class="input-box">
<input name="cfirebate[address]" id="cfirebate:address" title="<?php echo Mage::helper('contacts')->__('Address') ?>" class="input-text required-entry" type="text" />
</div>
</div>
<div class="field">
<label for="cfirebate:city" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('City') ?></label>
<div class="input-box">
<input name="cfirebate[city]" id="cfirebate:city" title="<?php echo Mage::helper('contacts')->__('City') ?>" class="input-text required-entry" type="text" />
</div>
</div>
<div class="field">
<div class="field">
<label for="cfirebate:region" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="cfirebate:region_id" name="cfirebate[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
<option value="">Please select region, state or province</option>
</select>
</div>
</div>
</div>
<div class="field">
<label for="cfirebate:postcode" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Zip') ?></label>
<div class="input-box">
<input name="cfirebate[postcode]" id="cfirebate:postcode" title="<?php echo Mage::helper('contacts')->__('Zip') ?>" class="input-text required-entry" type="text" />
</div>
</div>
<div class="field">
<label for="cfirebate:email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?></label>
<div class="input-box">
<input name="cfirebate[email]" id="cfirebate:email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" class="input-text required-entry validate-email" type="email" autocapitalize="off" autocorrect="off" spellcheck="false" />
</div>
</div>
</li>
<li>
<label for="cfirebate:telephone"><?php echo Mage::helper('contacts')->__('Phone Number') ?></label>
<div class="input-box">
<input name="cfirebate[telephone]" id="cfirebate:telephone" title="<?php echo Mage::helper('contacts')->__('Phone Number') ?>" class="input-text" type="tel" />
</div>
</li>
<li class="wide">
<label for="cfirebate:comment"><?php echo Mage::helper('contacts')->__('Comment') ?></label>
<div class="input-box">
<textarea name="cfirebate[comment]" id="cfirebate:comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="input-text" cols="5" rows="3"></textarea>
</div>
</li>
</ul>
</div>
<div class="buttons-set">
<input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
<button type="submit" title="<?php echo Mage::helper('contacts')->__('Submit') ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></span></button>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var contactForm = new VarienForm('contactForm', true);
var cfiRegionUpdater = new RegionUpdater('cfirebate:country_id', 'cfirebate:region', 'cfirebate:region_id', <?php echo $directory->getRegionJson() ?>, undefined, 'cfirebate:postcode');
//]]>
</script>
Try adding form key inside the form:
<input type="hidden" name="form_key" value="<?php echo $this->getFormKey(); ?>">
Just add the above code anywhere inside your form markup.
I am new in php. I have a PHP script which auto generates a tracking number in mysql database cons_no is the name of the table, I wish to enter the cons_no data manually.
Also when I try to edit the cons_no value from the edit page, other things are allowed to be edited - except con_no. Any help will be appreciated.
This is the code that creates the the file with the cons_no value.
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
session_start();
//Include database configuration file
require_once('database-settings.php');
require_once('database.php');
$db = conexion();
require_once('library.php');
require_once('funciones.php');
require 'requirelanguage.php';
include_once "filtro/class/class.php";;
include_once "filtro/class_buscar.php";
require_once("filtro/class/class.inputfilter.php");
$ifilter = new InputFilter();
$_POST = $ifilter->process($_POST);
$sql = "SELECT DISTINCT(off_name)
FROM offices";
$result = dbQuery($sql);
$company=mysql_fetch_array(mysql_query("SELECT * FROM company"));
date_default_timezone_set($_SESSION['ge_timezone']);
$fechai=date('Y-m-d');
$fechaf=date('Y-m-d');
isUser();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?php echo $_SESSION['ge_cname']; ?> | <?php echo $ENVIOS; ?></title>
<meta name="description" content="<?php echo $_SESSION['ge_description']; ?>"/>
<meta name="keywords" content="<?php echo $_SESSION['ge_keywords']; ?>" />
<meta name="author" content="Jaomweb">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<link rel="shortcut icon" type="image/png" href="img/favicon.png"/>
<link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="../bower_components/animate.css/animate.css" type="text/css" />
<link rel="stylesheet" href="../bower_components/font-awesome/css/font-awesome.min.css" type="text/css" />
<link rel="stylesheet" href="../bower_components/simple-line-icons/css/simple-line-icons.css" type="text/css" />
<link rel="stylesheet" href="css/font.css" type="text/css" />
<link rel="stylesheet" href="css/app.css" type="text/css" />
<link href="css/style.css" rel="stylesheet" media="all">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600' rel='stylesheet' type='text/css'>
<!-- Switchery css -->
<link href="assets/plugins/switchery/switchery.min.css" rel="stylesheet" />
<!-- Plugins css -->
<link href="assets/plugins/timepicker/bootstrap-timepicker.min.css" rel="stylesheet">
<link href="assets/plugins/mjolnic-bootstrap-colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
<link href="assets/plugins/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet">
<link href="assets/plugins/clockpicker/bootstrap-clockpicker.min.css" rel="stylesheet">
<link href="assets/plugins/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">
</head>
<body>
<?php
include("header.php");
?>
<!-- content -->
<div id="content" class="app-content" role="main">
<div class="app-content-body ">
<div class="wrapper-md">
<div class="row">
<div class="col-sm-12">
<div class="blog-post">
<div class="panel">
<div class="wrapper-lg">
<div>
<tbody>
<div class="row alertaCaja" style="display: none;">
<div class="col-xs-4 col-sm-4 col-md-4" style="float: none; margin: 0 auto;">
<div class="alert alert-dismissible alert danger">
<button type="button" class="close" data-dismiss="alert"><img src="img/close.png" height="15" width="15"></button>
<center>
<?php
require_once('database.php');
$query= mysql_query("SELECT MAX(cid) AS id FROM courier");
if ($row = mysql_fetch_row($query))
{
?>
<a target="_blank" href="print-invoice/invoice-print.php?cid=<?php echo codificar($id = trim($row[0])); ?>">
<img src="img/print-invoice.png" height="76" width="79"></a>
<?php } ?>
<?php
require_once('database.php');
$query= mysql_query("SELECT MAX(cid) AS id FROM courier");
if ($row = mysql_fetch_row($query))
{
?>
<a target="_blank" href="print-invoice/ticket-print.php?cid=<?php echo codificar($id = trim($row[0])); ?>">
<img src="img/print_label.png" height="76" width="79"></a>
<?php } ?>
</center>
</div>
</div>
</div>
<?php if ( isset ( $_GET ['tipo'] ) ) { ?>
<div class="row alertaCaja" style="display: none;" >
<div class="col-xs-6 col-sm-6 col-md-6" style="float: none; margin: 0 auto;">
<div class="alert alert-dismissible alert-<?php echo $_GET ['tipo'] ?>">
<button type="button" class="close" data-dismiss="alert">x</button>
<strong><?php echo $L_['message']; ?></strong><br/><br/> <?php echo $_GET ['mensaje']; ?>
</div>
</div>
</div>
<?php } ?>
<tr>
<h3 class="classic-title"><span><strong><i class="fa fa-truck icon text-default-lter"></i> <?php echo $ADICIONAR; ?></strong></h3>
<!-- START Checkout form -->
<form action="settings/add_courier/agregar.php" method="post" >
<table border="0" align="center" width="100%" >
<div class="row">
<!-- START Presonal information -->
<fieldset class="col-md-6">
<legend><?php echo $datosremite; ?></legend>
<!-- Name -->
<div class="row" >
<div class="col-sm-2 form-group">
<label class="control-label"><i class="fa fa-user icon text-default-lter"></i> <?php echo $StaffRole; ?><span class="required-field">*</span></label>
<input type="text" class="form-control" name="officename" id="officename" value="<?php echo $_SESSION['user_type'] ;?>" readonly="true" />
</div>
<div class="col-sm-2 form-group">
<label class="control-label"><i class="fa fa-user icon text-default-lter"></i> <?php echo $StaffUser; ?><span class="required-field">*</span></label>
<input type="text" class="form-control" name="user" id="user" value="<?php echo $_SESSION['user_name'] ;?>" readonly="true" />
</div>
<div class="col-sm-8 form-group">
<label class="control-label" ><?php echo $NOMBREREMITENTE; ?><span class="required-field">*</span></label>
<input type="text" class="form-control" name="Shippername" id="Shippername" autocomplete="on" list="customers" />
<datalist id="customers">
<?php
$sql=mysql_query("SELECT * FROM tbl_clients");
while($row=mysql_fetch_array($sql)){
echo '<option data-value="'.$row['id'].'">'.utf8_encode($row['name']).'</option>';
}
?>
</datalist>
<input type="hidden" name="Shippername-hidden" id="Shippername-hidden" />
</div>
</div>
<div class="row">
<div id="divRemi">
<div class="col-sm-6 form-group">
<label class="control-label"><?php echo $DIRECCION; ?><span class="required-field">*</span></label>
<input type="text" class="form-control" name="Shipperaddress" id="Shipperaddress" placeholder="<?php echo $placeremi; ?>" />
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><i class="fa fa-phone icon text-default-lter"></i> <?php echo $TELEFONO; ?></label>
<input type="tel" class="form-control" name="Shipperphone" id="Shipperphone" placeholder="<?php echo $placetele; ?>" />
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><?php echo $CEDULA; ?></i></label>
<input type="text" class="form-control" name="Shippercc" id="Shippercc" placeholder="<?php echo $placeced; ?>" >
</div>
<div class="col-sm-3 form-group" style="display:none">
<label class="control-label"><?php echo $L_['lockerid']; ?></i></label>
<input type="text" class="form-control" name="Shipperlocker" id="Shipperlocker" placeholder="<?php echo $L_['lockerid']; ?>">
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><i class="fa fa-angle-double-right icon text-default-lter"></i> <strong><?php echo $PAISORIGEN; ?></strong></label>
<input type="text" class="form-control" name="Pickuptime" id="Shippercountry" placeholder="<?php echo $L_['placecountry']; ?>">
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><strong><?php echo $L_STATE; ?></strong></label>
<input type="text" class="form-control" name="state" id="Shipperstate" placeholder="<?php echo $L_['placestate']; ?>">
</div>
<div class="col-sm-3 form-group" style="display:none">
<label class="control-label"><strong><?php echo $CODIGO; ?></strong></label>
<input type="text" class="form-control" name="iso" id="Shipperiso" placeholder="<?php echo $L_['placeiso']; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><strong><?php echo $CIUDAD; ?></strong></label>
<input type="text" class="form-control" id="Shipperciudad" name="ciudad" placeholder="<?php echo $L_['placecity']; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><strong><?php echo $CODIGOPOSTAL; ?></strong></label>
<input type="text" class="form-control" id="Shipperzipcode" name="zipcode" placeholder="<?php echo $codigopostal; ?>">
</div>
<div class="col-sm-12 form-group">
<p class="error"></p>
<label class="control-label"><?php echo $EMAIL; ?><font color="#FF6100"><?php echo $notaemail; ?></font></i></label>
<input type="email" class="form-control" name="Shipperemail" id="idemail" placeholder="demo#emo.com" autocomplete=" off" onKeyUp="javascript:validateeMail('idemail')" />
<strong><span id="mailOK"></span></strong>
<p class="error"></p>
</div>
</div>
</div>
<!-- Adress and Phone -->
<!-- START Shipment information -->
</br></br>
<legend><?php echo $Informaciondeenvio; ?></legend>
<div class="row">
<!-- Origin Office -->
<div class="col-sm-3 form-group">
<label for="zipcode" class="control-label"><i class="fa fa-angle-double-right icon text-default-lter"></i> <strong><?php echo $OFICINAORIGEN; ?></strong></label>
<select class="form-control" name="Invoiceno">
<?php
while($data = dbFetchAssoc($result)){
?>
<option value="<?php echo $data['off_name']; ?>"><?php echo $data['off_name']; ?></option>
<?php
}//while
?>
</select>
</div>
<div class="col-sm-3 form-group">
<label for="ccv" class="control-label"><strong><?php echo $CantidadPaquetes; ?></strong></i></label>
<input type="number" class="form-control" name="Qnty" placeholder="<?php echo $placecant; ?>" />
</div>
<!-- Text area -->
<div class="col-sm-6 form-group">
<label for="inputTextarea" class="control-label"><i class="fa fa-comments icon text-default-lter"></i> <?php echo $DetallesdelEnvio; ?></label>
<textarea class="form-control" name="Comments" placeholder="<?php echo $placedetails; ?>" ></textarea>
</div>
</div>
<div class="row">
<div class="col-sm-5 form-group">
<label class="control-label"><i class="fa fa-database icon text-default-lter"></i> <strong><?php echo $Pagos; ?></strong></label>
<select class="form-control" name="bookingmode">
<option selected="selected" value="Effective"><?php echo $Effective; ?></option>
<option value="Debit_card"><?php echo $Debitcard; ?></option>
<option value="Credit_card"><?php echo $Creditcard; ?></option>
<option value="Transfer"><?php echo $Transfer; ?></option>
<option value="Online"><?php echo $Payonline; ?></option>
<option value="Paypal"><?php echo $L_['type_paypal']; ?></option>
</select>
</div>
<div class="col-sm-4 form-group">
<label class="control-label"><?php echo $TipodeProducto; ?></label>
<select type="text" class="form-control" name="Shiptype" >
<?php
$sql="SELECT name FROM type_shipments GROUP BY name";
$query=$db->query($sql);
if($query->num_rows>0){
while($row=$query->fetch_array()){
echo '<option data-value="'.$row['name'].'">'.utf8_encode($row['name']).'</option>';
}
}
?>
</select>
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><i class="fa fa-plane icon text-default-lter"></i> <?php echo $MododelServicio; ?></label>
<select class="form-control" name="Mode">
<?php
$sql="SELECT name FROM mode_bookings GROUP BY name";
$query=$db->query($sql);
if($query->num_rows>0){
while($row=$query->fetch_array()){
echo '<option data-value="'.$row['name'].'">'.utf8_encode($row['name']).'</option>';
}
}
?>
</select>
</div>
</div>
<!-- Payment Mode -->
<div class="row">
<div class="col-sm-3 form-group" >
<label class="text-danger"><strong><?php echo $_SESSION['ge_curr']; ?> <?php echo $ValorDeclarado; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="suma();" id="sum2" name="Totaldeclarate" value="0" />
</div>
<div class="col-sm-3 form-group" >
<label class="text-danger"><strong><?php echo $Declarado; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="suma();" id="sum5" name="Totaldeclarado" value="4" />
</div>
<div class="col-sm-3 form-group">
<label for="ccv" class="text-danger"><strong><?php echo $_SESSION['ge_curr']; ?> <?php echo $ValorRecogida; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="suma();" id="sum3" name="Totalfreight" value="0" />
</div>
<div class="col-sm-3 form-group">
<label class="text-danger"><strong><?php echo $_SESSION['ge_curr']; ?> <?php echo $PrimerKilo; ?> <?php echo $_SESSION['ge_measure']; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="suma();" id="sum1" name="variable" value="3.25" />
</div>
<div class="col-sm-3 form-group">
<label class="text-danger"><strong><?php echo $_SESSION['ge_curr']; ?> <?php echo $_SESSION['ge_measure']; ?> <?php echo $KiloAdicional; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="suma();" id="sum6" name="kiloadicional" value="3.25" />
</div>
<div class="col-sm-3 form-group">
<label class="text-danger"><strong><?php echo $PesoKg; ?> (<?php echo $_SESSION['ge_measure']; ?>)<strong></label>
<input type="text" class="form-control" required onblur="if(this.value == ''){this.value='0'}" onKeyUp="suma();" id="sum4" name="Weight" value="0" />
</div>
<div class="col-sm-3 form-group">
<label class="text-danger"><strong><?php echo $SubtotalEnvio; ?><strong></i></label>
<input type="text" class="form-control" name="shipping_subtotal" id="resultado" value="0" />
</div>
<div class="col-sm-3 form-group">
<label class="text-danger"><strong><?php echo $_SESSION['ge_curr']; ?> <?php echo $PesoFisico; ?><strong></label>
<input type="text" class="form-control" id="pesoreal" name="pesoreal" onblur="if(this.value == ''){this.value='0'}" >
</div>
</div>
<legend><?php echo $pesovolumetrico; ?>:</legend>
<!-- Peso Volumetrico -->
<div class="row">
<div class="col-sm-3 form-group">
<label class="text-primary"><strong><?php echo $Altura; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="volumetrico();" id="volume1" name="altura" placeholder="<?php echo $Altura; ?>" />
</div>
<div class="col-sm-3 form-group">
<label class="text-primary"><strong><?php echo $Ancho; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="svolumetrico();" id="volume2" name="ancho" placeholder="<?php echo $Ancho; ?>" />
</div>
<div class="col-sm-3 form-group">
<label class="text-primary"><strong><?php echo $Longitud; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="volumetrico();" id="volume3" name="longitud" placeholder="<?php echo $Longitud; ?>" />
</div>
<div class="col-sm-3 form-group">
<label class="text-primary"><strong><?php echo $TotalPesoVolumetrico; ?><strong></i></label>
<input type="text" class="form-control" name="totalpeso" id="totalpeso" placeholder="0,00" />
</div>
</div>
</fieldset>
<!-- START Receiver info -->
<fieldset class="col-md-6">
<legend><?php echo $DatosDestinatario; ?></legend>
<!-- Name -->
<div class="form-group">
<label class="control-label"><?php echo $NOMBREDESTINATARIO; ?><span class="required-field">*</span></label>
<input type="text" class="form-control" name="Receivername" id="Receivername" autocomplete="on" list="customers" >
</div>
<!-- Adress and Phone -->
<div class="row">
<div class="col-sm-3 form-group">
<label class="control-label"><?php echo $DIRECCION; ?><span class="required-field">*</span></label>
<input type="text" class="form-control" name="Receiveraddress" id="Receiveraddress" placeholder="<?php echo $placedirdesti; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><i class="fa fa-phone icon text-default-lter"></i> <?php echo $TELEFONO; ?></label>
<input type="tel" class="form-control" name="Receiverphone" id="Receiverphone" placeholder="<?php echo $placeteldesti; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><i class="fa fa-phone icon text-default-lter"></i> <?php echo $TELEFONO2; ?></label>
<input type="tel" class="form-control" name="telefono1" id="Receivertelefono1" placeholder="<?php echo $placeteldesti; ?>">
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><?php echo $CEDULA; ?></i></label>
<input type="text" class="form-control" name="Receivercc_r" id="Receivercc_r" placeholder="<?php echo $L_['placecedr']; ?>">
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><i class="fa fa-angle-double-right icon text-default-lter"></i> <strong><?php echo $PAISDESTINO; ?></strong></label>
<input type="text" class="form-control" name="paisdestino" id="Receivercountry1" placeholder="<?php echo $L_['placecountry1']; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><strong><?php echo $L_STATE; ?></strong></label>
<input type="text" class="form-control" name="state1" id="Receiverstate1" placeholder="<?php echo $L_['placestate']; ?>" >
</div>
<div class="col-sm-3 form-group" style="display:none">
<label class="control-label"><strong><?php echo $CODIGO; ?></strong></label>
<input type="text" class="form-control" name="iso1" id="Receiveriso1" placeholder="<?php echo $L_['placeiso']; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><strong><?php echo $CIUDAD; ?></strong></label>
<input type="text" class="form-control" name="city1" id="Receivercity1" placeholder="<?php echo $L_['placecity']; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><strong><?php echo $CODIGOPOSTAL; ?></strong></label>
<input type="text" class="form-control" name="zipcode1" id="Receiverzipcode1" placeholder="<?php echo $codigopostal; ?>">
</div>
<div class="col-sm-12 form-group">
<p class="error"></p>
<label class="control-label"><?php echo $EMAIL; ?><font color="#FF6100"><?php echo $notaemail; ?></font></i></label>
<input type="email" class="form-control" name="Receiveremail" id="id_mail" placeholder="demo#emo.com" onKeyUp="javascript:validateMail('id_mail')" >
<strong><span id="emailOK"></span></strong>
<p class="error"></p>
</div>
</div>
</br></br>
<!-- Name -->
<div class="form-group">
<label for="name-card" class="text-success"><strong><?php echo $NUMEROENVIO; ?></strong></label>
<?php
$qryEmpresa = mysql_query("SELECT * FROM company");
while($row = mysql_fetch_array($qryEmpresa)) {
$pre = $row["prefijo"];
$cons = $row["cons_no"];
}
mysql_free_result($qryEmpresa);
$pa=mysql_query("SELECT MAX(cons_no)as maximo FROM c_tracking");
if($row=mysql_fetch_array($pa)){
if($row['maximo']==NULL){
$cons_no=''.$cons.'';
}else{
$cons_no=$row['maximo']+1;
}
}
?>
<input type="text" class="form-control" value="<?php echo $_SESSION['ge_prefix']; ?>-<?php echo "".$cons_no; ?>">
</div>
</br>
<!-- Status and Pickup Date -->
<div class="form-group">
<label for="dtp_input1" class="control-label"><i class="fa fa-calendar icon text-default-lter"></i> <?php echo $FECHARECOLECCIONENVIO; ?></i></label>
<div>
<div class="input-group">
<input type="text" class="form-control" name="Packupdate" placeholder="mm/dd/yyyy" id="datepicker-autoclose" >
<span class="input-group-addon bg-custom b-0"><i class="glyphicon glyphicon-calendar"></i></span>
</div><!-- input-group -->
</div>
</div>
<div class="row">
<div class="col-sm-4 form-group">
<label for="month" class="control-label"><i class="fa fa-sort-amount-asc icon text-default-lter"></i> <?php echo $estado; ?></label>
<select class="form-control" name="status" id="status">
<?php
$sql="SELECT servicemode FROM service_mode GROUP BY servicemode";
$query=$db->query($sql);
if($query->num_rows>0){
while($row=$query->fetch_array()){
echo '<option data-value="'.$row['servicemode'].'">'.utf8_encode($row['servicemode']).'</option>';
}
}
?>
</select>
</div>
<div class="col-sm-8 form-group">
<label for="dtp_input1" class="control-label"><i class="fa fa-calendar icon text-default-lter"></i> <?php echo $fechaestimadadeliver; ?></i></label>
<div>
<div class="input-group">
<input type="text" class="form-control" name="Schedule" placeholder="mm/dd/yyyy" id="datepicker">
<span class="input-group-addon bg-custom b-0"><i class="glyphicon glyphicon-calendar"></i></span>
</div><!-- input-group -->
</div>
</fieldset>
<div class="col-md-6 text-left">
</br></br>
<button type="submit" id="submit" class="btn btn-large btn-success"><?php echo $GUARDARENVIO; ?></button>
</div>
</div>
</div>
</div>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- / content -->
<?php include("footer.php"); ?>
<?php include("footer_add_courier.php"); ?>
I'm trying to turn a input into a checkbox on my form. When checked I want the value to be 1 and unchecked to be zero. I tried a few things but on submit the value doesnt get added into the db.
HTML-1:
<div class="col-sm-5 col-sm-push-1 form-group required">
<label class="control-label" for="input-active"><?php echo $entry_active; ?></label>
<div class="input-active required">
<input type="checkbox" name="active" value="0" placeholder="<?php echo $text_active; ?>" id="input-active" class="form-control" />
</div>
<?php if (isset($error_date_starting)) { ?>
<label class="text-danger"><?php echo $error_code; ?></label>
<?php } ?>
</div>ut type="checkbox" name="active" value="0" placeholder="<?php echo $text_active; ?>" id="input-active" class="form-control" />
</div>
<?php if (isset($error_date_starting)) { ?>
<label class="text-danger"><?php echo $error_code; ?></label>
<?php } ?>
</div>
HTML-2:
<div class="col-sm-5 col-sm-push-1 form-group required">
<label class="control-label" for="input-active"><?php echo $entry_active; ?></label>
<div class="input-active required">
<input type="hidden" name='active' value='0' placeholder="<?php echo $text_active; ?>" id="input-active" class="form-control" />
<input type="checkbox" name='active' value='1' placeholder="<?php echo $text_active; ?>" id="input-active" class="form-control" />
</div>
<?php if (isset($error_date_starting)) { ?>
<label class="text-danger"><?php echo $error_code; ?></label>
<?php } ?>
</div>
I tried a few Javascripts solutions but none worked:
<script type="text/javascript">
$('#input-active').on('change', function(){
this.value = this.checked ? 1 : 0;
// alert(this.value);
}).change();
</script>
UPDATE!!
Still not working I've changed code following suggestions still not doing what I'd like.
New HTML:
<div class="col-sm-5 col-sm-push-1 form-group required">
<label class="control-label" for="input-active"><?php echo $entry_active; ?></label>
<div class="input-active required">
<input type="checkbox" name='active' value='0' placeholder="<?php echo $text_active; ?>" id="input-active" class="form-control" />
</div>
<?php if (isset($error_date_starting)) { ?>
<label class="text-danger"><?php echo $error_code; ?></label>
<?php } ?>
</div>
New JS:
<script type="text/javascript">
$("#input-active").change(function() {
if(this.checked) {
$("#input-active").val('1');
} else {
$("#input-active").val('0');
}
});
</script>
To catch the toggled event on input type please use the following function
$("#input-active").change(function() {
if($(this).is(':checked')) {
console.log('checked')
$(this).val(1);
} else {
console.log('un checked')
$(this).val(0);
}
console.log($(this).val())
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-sm-5 col-sm-push-1 form-group required">
<label class="control-label" for="input-active">In active</label>
<div class="input-active required">
<input type="checkbox" name='active' value='0' placeholder="Active" id="input-active" class="form-control" />
</div>
</div>
When i am try to update details using for loop it is updated as a empty(Null) to refer columns.
Below is my code please help me what wrong with my logic.
View Code
The No. of text fields are going to generate depends on no. of values present in table. It is executing in foreach loop
<form method="post" action="<?php echo site_url('Home/advisor_update'); ?>"
<?php
if ($advisor_emp->num_rows()>0 )
{
$i=1;
foreach($advisor_emp->result() as $data)
{
$eid = $data->id;
$cn = $data->company_name;
$fd = $data->from_date;
$td = $data->to_date;
$tb = $data->type_of_buisness;
$c1 = $data->company_addres_lane_1;
$c2 = $data->company_addres_lane_2;
$cc = $data->c_city;
$cp = $data->c_pincode;
$cs = $data->c_state;
$cun = $data->c_country; ?>
<div class="col-md-6">
<div class="form-group">
<input type="" name="eid[]" class="form-control" value="<?php echo $eid; ?>">
</div>
<div class="col-md-12">
<div class="form-group">
<label>Previous Employer</label>
<input type="text" class="form-control" name="pcmp" value="<?php echo $cn; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>From</label>
<input type="text" name="pcmpfrom" class="form-control" value="<?php echo $fd ; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>To</label>
<input type="text" name="pcmpto" class="form-control" value="<?php echo $td ; ?>">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>Designation</label>
<input type="text" name="pcmpdesi" class="form-control" value="<?php echo $tb;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Company Address Line 1</label>
<input type="text" name="pcmpadr1[]" class="form-control" value="<?php echo $c1;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Company Address Line 2</label>
<input type="text" name="pcmpadr2" class="form-control" value="<?php echo $c2;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>City</label>
<input type="text" name="pcmpcit" class="form-control" value="<?php echo $cc;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Pin Code</label>
<input type="text" name="pcmppin[]" class="form-control" value="<?php echo $cp;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>State</label>
<input type="text" name="pcmpstat[]" class="form-control" value="<?php echo $cs; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Country</label>
<input type="text" name="pcmpcun[]" class="form-control" value="<?php echo $cun; ?>">
</div>
</div>
</div>
<?php
$i++;
}
}
?>
<div class="col-md-12"
<input type="submit" class="btn btn-primary" name="advisor_update" value="Update" >
</div>
</form>
Here is my Controller
In controller i'm goin to getting data from the view using for loop and sending recieved data to modal.
if ($this->input->post('advisor_update'))
{
$emp_his_id = $this->input->post('eid');
$count_eid = count($emp_his_id);
for($i=0;$i<$count_eid;$i++)
{
$emp_his_pk = $emp_his_id[$i];
$inserte['company_name']= $this->input->post('cn');
$inserte['from_date']= $this->input->post('fd');
$inserte['to_date']= $this->input->post('td');
$inserte['type_of_buisness']= $this->input->post('tb');
$inserte['company_addres_lane_1']= $this->input->post('c1');
$inserte['company_addres_lane_2']= $this->input->post('c2');
$inserte['c_city']= $this->input->post('cc');
$inserte['c_pincode']= $this->input->post('cp');
$inserte['updated_on'] = date("Y-m-d");
$up_emp_history=$this->Frontend_model->update_employe($inserte=array(),$emp_his_pk);
}
}
Here is my Modal
function update_employe($inserte=array(),$emp_his_pk)
{
$this->db->where('id',$emp_his_pk);
$result=$this->db->update("is_employment", $inserte);
return $result;
}
View Code
I have change your view codes input name
<form method="post" action="<?php echo site_url('Home/advisor_update'); ?>" >
<?php
if ($advisor_emp->num_rows()>0 )
{
foreach($advisor_emp->result() as $data)
{
$eid = $data->id;
$cn = $data->company_name;
$fd = $data->from_date;
$td = $data->to_date;
$tb = $data->type_of_buisness;
$c1 = $data->company_addres_lane_1;
$c2 = $data->company_addres_lane_2;
$cc = $data->c_city;
$cp = $data->c_pincode;
$cs = $data->c_state;
$cun = $data->c_country; ?>
<div class="col-md-6">
<div class="form-group">
<input type="" name="eid[]" class="form-control" value="<?php echo $eid; ?>">
</div>
<div class="col-md-12">
<div class="form-group">
<label>Previous Employer</label>
<input type="text" class="form-control" name="cn[]" value="<?php echo $cn; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>From</label>
<input type="text" name="fd[]" class="form-control" value="<?php echo $fd ; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>To</label>
<input type="text" name="td[]" class="form-control" value="<?php echo $td ; ?>">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>Designation</label>
<input type="text" name="tb[]" class="form-control" value="<?php echo $tb;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Company Address Line 1</label>
<input type="text" name="c1[]" class="form-control" value="<?php echo $c1;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Company Address Line 2</label>
<input type="text" name="c2[]" class="form-control" value="<?php echo $c2;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>City</label>
<input type="text" name="cc[]" class="form-control" value="<?php echo $cc;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Pin Code</label>
<input type="text" name="cp[]" class="form-control" value="<?php echo $cp;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>State</label>
<input type="text" name="cs[]" class="form-control" value="<?php echo $cs; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Country</label>
<input type="text" name="cun[]" class="form-control" value="<?php echo $cun; ?>">
</div>
</div>
</div>
<?php
}
}
?>
Controller Code
You have to run a foreach loop in controller.
if ($this->input->post('advisor_update'))
{
$emp_his_id = $this->input->post('eid');
$cn = $this->input->post('cn');
$fd = $this->input->post('fd');
$td = $this->input->post('td');
$td = $this->input->post('tb');
$c1 = $this->input->post('c1');
$c2 = $this->input->post('c2');
$cc = $this->input->post('cc');
$cp = $this->input->post('cp');
foreach($emp_his_id as $key => $eid)
{
$emp_his_pk = $eid;
$inserte = array();
$inserte['company_name']= $cn[$key];
$inserte['from_date']= $fd[$key];
$inserte['to_date']= $td[$key];
$inserte['type_of_buisness']= $tb[$key];
$inserte['company_addres_lane_1']= $c1[$key];
$inserte['company_addres_lane_2']= $c2[$key];
$inserte['c_city']= $cc[$key];
$inserte['c_pincode']= $cp[$key];
$inserte['updated_on'] = date("Y-m-d");
$up_emp_history=$this->Frontend_model->update_employe($inserte=array(),$emp_his_pk);
}
}
Hope This works for you
My edit.php code is stated below, and this is what the outcome is: http://i.imgur.com/lt89Wi8.png
But what it is supposed to do is, get the information from the username - loggin_session, and show their server details , so they dont have to re-write everything.
see: http://i.imgur.com/fGEsXPq.png
<?php
$query = "SELECT id, username, name, url, banner, description, sponsor, votes FROM websites WHERE username = '$login_session'";
$result = mysql_query($query) OR die($mysql_error());
$num = mysql_num_rows($result);
if ($num < 1) {
$n = FALSE;
echo '<font color="red">You have no servers to edit, You can add one here</font><br />';
die();
} ?>
<form action="" method="post" name="join_form" class="form-horizontal" role="form" enctype="multipart/form-data" onSubmit="return checkform(this);">
<div class="form-group ">
<label for="join_email" class="col-md-1 control-label"><span class="required">*</span>Server Title</label>
<div class="col-md-5">
<input name="name" value="<?php echo $_POST['name']; ?>" class="form-control" placeholder="<?php echo ''.$row['name'].''?>" required>
</div>
</div>
<div class="form-group ">
<label for="join_password" class="col-md-1 control-label"><span class="required">*</span>Website URL</label>
<div class="col-md-5">
<input name="url" value="<?php if (isset($_POST['url'])) echo $_POST['url']; ?>" class="form-control" placeholder="<?php echo ''.$row['url'].''?>" required>
</div>
</div>
<div class="form-group ">
<label for="join_url" class="col-md-1 control-label"><span class="required">*</span>Banner URL</label>
<div class="col-md-5">
<input name="banner" value="<?php if (isset($_POST['banner'])) echo $_POST['banner']; ?>" class="form-control" type="text" placeholder="<?php echo ''.$row['banner'].''?>" required>
</div>
</div>
<div class="form-group ">
<label for="join_title" class="col-md-1 control-label"></label>
<div class="col-md-5"></div>
</div>
<div class="form-group ">
<label for="join_description" class="col-md-1 control-label"><span class="required">*</span>Descr..</label>
<div class="col-md-5">
<textarea cols="50" rows="5" value="<?php if(isset($_POST['description'])) echo $_POST['description']; ?>" name="description" id="description_size" class="form-control" placeholder="<?php echo ''.$row['description'].''?>" required></textarea>
</div>
</div>
<input type="submit" name="submit" value="Add" />
<input type="hidden" name="submitted" value="TRUE" />
</form>
$row is undefined in your code. It has to be
$row=mysql_fetch_assoc($result); // fetch it from the result set
How can I prevent SQL injection in PHP?
And what's up with that useless '' in every echo?
echo ''.$row['name'].''
^^ ^^
This is enough
echo $row['name'];