Insert after for dynamic row - javascript

I have a dynamic adding row button. I can add more Ids and more clients but when I click on the plus it adds them in the top of my page and not after my row. How do I do that? Here is my code :
<b>Dimanche</b> </br><?php echo $date1 ?>
</td>
<!-- numéro de projet du dimanche -->
<td>
<span id="numpro" >
<form method="post" action="" onsubmit="return false;">
<input type="text" id="name" name="add_name"onkeypress="return handleEnter(event, this, 'task');"/></br>
<?php
if($result!=false && mysqli_num_rows($result)>0)
{
while($product = mysqli_fetch_array($result)): ?>
<p id="oldRow<?=$product['id']?>">
<input type="text" name="name<?=$product['id']?>" value="<?=$product['name']?>" /></p>
<?php endwhile; } ?>
</span>
<input onclick="addRow(this.form);" type="button" value="+" />
</td>
</form>
<html>
<div >
<form method="post" >
<div id="itemRows">
<?php
if($result!=false && mysqli_num_rows($result)>0)
{
while($product = mysqli_fetch_array($result)): ?>
<p id="oldRow<?=$product['id']?>">
<input type="text" name="name<?=$product['id']?>" value="<?=$product['name']?>" /></p>
<?php endwhile; } ?>
</div>
<p><input type="submit" name="ok" value="Ajouter à la B.D"></p>
</form>
</div>
<script type="text/javascript">
var rowNum = 0;
function addRow(frm) {
rowNum ++;
var row = '<p id="rowNum'+rowNum+'"> <input type="text" name="name[]" value="'+frm.add_name.value+'"> <input type="text" name="client1[]" size="12" class = "client1" id ="client1" disabled value="'+frm.client1.value+'"><input type="button" value="-" onclick="removeRow('+rowNum+');"></p>';
jQuery('#itemRows').append(row);
frm.add_client1.value = '';
frm.add_name.value = '';
}
function removeRow(rnum) {
jQuery('#rowNum'+rnum).remove();
}
</script>
</span>
</td>
</td>
<!-- client du dimanche -->
<td>
<span id="proclient">
<input type="text" name="client1" size="12" class = "client1" id ="client1" disabled />
</span>
</td>
<!-- description du projet de dimanche -->
<td>
<span id="prodesc">
<input type="text" name="desc1" size="30" id ="desc1" class "desc" disabled />
</span>
</td>
<!-- ddescription de la tache du dimanche -->
<td>
<span id="protache">
<textarea rows="1" cols="20" name="taskDesc1" id ="task1" class "task"> </textarea>
</span>
</td>
<!-- lieu pour dimanche -->
<td>
<span id="prolieu">
<input type="text" name="prolieu1" size="10" id ="lieu1" class "lieu">
</span>
</td>
<!-- tache -->
<td>
<span id="tache">
<!-- <input type="text" name="tache" size="30" id="tache"class= "tache" /> -->
<!-- début section cobobox tache avec tool tip -->
<label title="Select your state"> <select title="Select your state" id="state" name="state">
<?php
$stmt->execute();
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo ' <option title="';
echo $row['tacName'];
echo '">';
echo $row['tacId'];
echo '</option>'."\n";
$task = array();
//echo '<option value="'.$row['tacName'].'">'.$row['tacId'].'</option>'."\n";
}
?>
</select>
</label>
<!-- Fin section cobobox tache avec tool tip -->
</span>
</td>
<!-- calculter le temps pour le diamnche -->
<td>
<span id="calculTemps">
<input type="number" name="tempsd" size="30" id="temps1"class= "temps" min= "0" max="24" value="0" />
</span>
</td>
EDIT Here a demo of my problem
EDIT Here a demo of my goal I want

Try to use JQuery functions insertAfter and appendTo together with selectors :last or :first.
Common examples: jQuery('<p>').html('Some content').insertAfter('#id_here:last'); jQuery('<p>').html('Some content').appendTo('#itemRows');

Related

Enable Edit button if new record exists

I created a modal where I can insert new client record and edit the same record. But in relation to the edit button, I wanted it to be active only when there was a new record in the database and until the end of the day it was registered.
<a type="button" name="editar" id="'.$row["IdCliente"].'" data-toggle="modal" href="#add_data_Modal" class="btn btn-primary edit_data">Update</a>
I'm trying this way:
if(isset($_POST["employee_id3"]))
{
$output = '';
$query = "SELECT * FROM centrodb.PsicUtentes LEFT OUTER JOIN centrodb.PsicUtentesConsulta ON centrodb.PsicUtentesConsulta.CodigoUtente2 = centrodb.PsicUtentes.CodigoUtente WHERE centrodb.PsicUtentes.Id = '".$_POST["employee_id3"]."' ORDER BY IdConsulta DESC ";
$result = mysqli_query($conn, $query);
$output;
while($row = mysqli_fetch_array($result))
{
$dataAtual = DATE('Y-m-d');
$disabled = "";
if(DATE($row['Data2'])!=$dataAtual){
$disabled = "disabled";
}
$output .= '
<h4 class="modal-title">Histórico de Consultas</h4>
<div>
<button type="button" class="exibir botao" href="#" aria-hidden="true">+</button>
<button type="button" href="#" class="ocultar botao" aria-hidden="true">-</button>
</div>
<div class="conteudo">
<form method="post" id="insert_form6">
<div style="float:right">
<a type="button" name="edit3" id="'.$row["Id"].','.$row["IdConsulta"].'" data-toggle="modal" href="#add_data_Modal3" class="btn btn-primary edit_data3" "$disabled">Editar</a>
</div>
<br/>
<br/>
<br/>
<fieldset class="grupo">
<table class="campo" cellspacing="10">
<tr>
<td>
<input type="Hidden" id="IdConsulta1" name="IdConsulta" class="form-control" value="'.$row["IdConsulta"].'" style="width:150px;" readonly="true" />
</td>
<td>
<label>Data Consulta</label>
<input type="text" id="Data23" name="Data2" class="form-control" value="'.$row["Data2"].'" style="width:150px;" readonly="true" />
</td>
<td>
<label>Código Utente</label>
<input type="number" id="CodigoUtente5" name="CodigoUtente" value="'.$row["CodigoUtente"].'" class="form-control" style="width:100px;" readonly="true"/>
</td>
<td>
<label>Nome Utente</label>
<input type="text" id="Nome5" name="Nome" value="'.$row["Nome"].'" class="form-control" style="width:400px;" readonly="true"/>
</td>
<td>
<label>Data Nascimento</label>
<input type="date" id="DataNasc5" name="DataNasc" value="'.$row["DataNasc"].'" class="form-control" style="width:150px;" readonly="true"/>
</td>
</tr>
</table>
</fieldset>
<fieldset class="grupo">
<table class="campo" cellspacing="10">
<tr>
<td>
<label>Data Admissao</label>
<input type="date" id="DataAdmissao5" name="DataAdmissao" value="'.$row["DataAdmissao"].'" class="form-control" style="width:150px;" readonly="true"/>
</td>
<td>
<label>Valência</label>
<input type="text" id="ValenciasDescricao5" name="ValenciasDescricao" value="'.$row["ValenciasDescricao"].'" class="form-control" style="width:200px;" readonly="true"/>
</td>
</tr>
</table>
</fieldset>
<fieldset class="grupo">
<table class="campo" cellspacing="10">
<tr>
<td>
<label>Observação</label>
</p><textarea rows="6" cols="130" readonly="true">'.$row["Descricao"].'</textarea>
</td>
</tr>
</table>
</fieldset>
<fieldset class="grupo">
<table class="campo" cellspacing="10">
<tr>
<td>
<label>O Psicologo/a</label>
<input type="text" id="Colaborador2" name="Colaborador2" class="form-control" style="width:150px;" value="'.$row["Colaborador2"].'" readonly="true"/>
</td>
</tr>
</table>
</fieldset>
</form>
</div>
';
}
$output;
echo $output;
}
<script>
$(document).ready(function(){
$(document).on('click', '.edit_data3', function(){
var employee_id3 = $(this).attr("Id");
$.ajax({
url:"./fetch2",
method:"POST",
data:{employee_id3:employee_id3},
dataType:"json",
success:function(data){
$('#IdConsulta').val(data.IdConsulta);
$('#Data22').val(data.Data2);
$('#CodigoUtente6').val(data.CodigoUtente2);
$('#Descricao1').val(data.Descricao);
$('#Colaborador2').val(data.Colaborador2);
$('#employee_id3').val(data.Id);
$('#insert3').val("Gravar");
$('#add_data_Modal3').modal('show');
}
});
});
$('#insert_form7').on("submit", function(event){
event.preventDefault();
if($('#CodigoUtente6').val() == "")
{
alert("Código Utente é necessário");
}
else if($('#Descricao1').val() == "")
{
alert("Observação é necessária");
}
else
{
$.ajax({
url:".conexao9",
method:"POST",
data:$('#insert_form7').serialize()
,
beforeSend:function(){
$('#insert3').val("Inserting");
},
success:function(data){
$('#insert_form7')[0].reset();
$('#add_data_Modal3').modal('hide');
$('#employee_table').html(data);
location.reload("add_data_Modal3");
}
});
}
});
});
</script>
I created a variable with the current date that compares with the date of the record. I created an empty disabled variable. There I put this disabled variable in the link. If the date is different than the current date you put the disabled variable filled.The problem is that the button stays in the same asset.
Firstly your code is vulnerable to sql injection attacks and you should use prepared statements.
Then you have some syntax errors on your code.
The lines $output; are useless, delete them.
Change "$disabled" to '.$disabled'.
and put ?> before your <script> tag.

Add an input field, text area, dropdown to the form at the same time you can modify/edit the form

How can I modify this form, (to be able to add a textarea, dropdown, or even edit the text area into dropdown)
I know I should use javascript but I tried several times, it doesn't work.
Below are my codes.**
I am using the MVC method of coding
This is in ModifyVersantExam.php
<?php
$this->layout = '~/views/shared/_mainLayout.php';
$this->section['title'] = 'Versant Exam';
$this->section['username'] = $user['name'];
?>
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<h3><strong><center><?php echo $exam[0]['versant_exam_title'];?></center></strong></h3>
<br />
<form id="form" class="form-horizontal form-label-left" method="POST" action="./">
<?php $display = 'style="display:none"';
foreach($question as $ques){
?>
<!-- Input Area -->
<div class="form-group" id='' name='' <?php echo $i = ($ques['versant_examquestions_type']==1)? "":"$display";?> >
<label class="col-sm-2 control-label" for="<?php echo $ques['versant_examquestions_id'];?>"><?php echo $ques['versant_examquestions_question'];?></label>
<div class='col-sm-8'>
<input class='form-control' type='text' id='<?php echo $ques['versant_examquestions_id'];?>' name='<?php echo $ques['versant_examquestions_id'];?>' required>
</div>
</div>
<!-- Textarea Area -->
<div class="form-group" id='' name='' <?php echo $i = ($ques['versant_examquestions_type']==2)? "":"$display";?> >
<label class="col-sm-2 control-label" for="<?php echo $ques['versant_examquestions_id'];?>"><?php echo $ques['versant_examquestions_question'];?></label>
<div class='col-sm-8'>
<textarea class='form-control' id='<?php echo $ques['versant_examquestions_id'];?>' name='<?php echo $ques['versant_examquestions_id'];?>' required></textarea>
</div>
</div>
<!-- Select Area -->
<div class="form-group" id='' name='' <?php echo $i = ($ques['versant_examquestions_type']==3)? "":"$display";?> >
<label class="col-sm-2 control-label" for="<?php echo $ques['versant_examquestions_id'];?>"><?php echo $ques['versant_examquestions_question'];?></label>
<div class='col-sm-8'>
<select class="form-control" id="<?php echo $ques['versant_examquestions_id'];?>" name="<?php echo $ques['versant_examquestions_id'];?>" required>
<option value="0">---Select---</option>
<?php
foreach($options as $loopoption){
if($loopoption['versant_examoptions_questionid'] == $ques['versant_examquestions_id']){ ?>
<option value="<?php echo $loopoption['versant_examoptions_id']; ?>"><?php echo $loopoption['versant_examoptions_options']; ?></option>
<?php }
}
?>
</select>
</div>
</div>
<!-- Radio Button Area -->
<div class="form-group" <?php echo $i = ($ques['versant_examquestions_type']==4)? "":"$display";?> >
<label class="col-sm-2 control-label" for="">Radio Button 1:</label>
<div class="radio">
<label>
<input type="radio" checked="" value="option1" id="optionsRadios1" name="optionsRadios"> Option one. only select one option
</label>
</div>
<label class="col-sm-2 control-label" for="blank"> </label>
<div class="radio">
<label>
<input type="radio" value="option2" id="optionsRadios2" name="optionsRadios"> Option two. only select one option
</label>
</div>
</div>
<?php }?>
<br /><br />
<?php
$i=1;
$k = 0;?>
<td><input name='title[]' type='text' placeholder='Title' class='form-control input-md' width = "30" autocomplete='off'/> </td>
<td data-name=\"sel\">
<select class='form-control chos' name='sel[]'><option value=''>Select Option</option>
<option value='1'>Input</option>
<option value='2'>Text Field</option>
<option value='3'>Dropdown</option></select>
<br />
<div class='row ' style='display:none;' id='options'>
<div class='form-group form-group-options col-xs-11 col-sm-8 col-md-12'>
<div class='input-group input-group-option col-xs-12'>
<input type='text' name='option["<?php $k+1 ?>"][]' class='form-control' placeholder='Type here' autocomplete='off'>
<span class='input-group-addon input-group-addon-remove'>
<span class='glyphicon glyphicon-remove'></span>
</span>
</div>
</div>
</div>
<td id='require0'>
<div>
<center><label><input type='checkbox'id='versant_required' name= 'versant_examquestions_required["<?php $k+1 ?>"]' value='1'/> Required? </label></center>
</div>
</td>
</td>
<br><br>
<center>
<button id="add_row" onclick = "addrow()" class="btn btn-info">Add Row</button>
<a id="delete_row" class="btn btn-danger">Delete Row</a>
<br><br>
<a class="btn btn-danger pull-right">Cancel</a>
<a class="btn btn-primary pull-right">Save</a>
</center>
</form>
</div>
</div>
</div>
<?php
$this->section['script'] = "
<script src='/emsTest/lib/datatable/jquery.dataTables.min.js'></script>
<script src='/emsTest/lib/datatable/dataTables.bootstrap.js'></script>
<script src='/emsTest/lib/datatable/dataTables.keyTable.min.js'></script>
<script src='/emsTest/lib/datatable/dataTables.responsive.min.js'></script>
<script src='/emsTest/lib/datatable/dataTables.scroller.min.js'></script>
<script src='/emsTest/lib/datatable/responsive.bootstrap.min.js'></script>
<script src='/emsTest/custom_scripts/Recruitment/VersantModifyExamBuilder.js'></script>
<script src='/emsTest/custom_scripts/Recruitment/versant.js'></script>";
$(document).ready(function() {
$('#options').hide();
//Add Rows
var i=1;
var k = 0;
$("#add_row").click(function(){
$('#addr'+i).html("<td><center>"+ (i+1) +"</center></td>\n\
<td><input name='title[]' type='text' placeholder='Title' class='form-control input-md' autocomplete='off'/> </td>\n\
<td data-name=\"sel\">\n\
<select class='form-control chos' name='sel[]'><option value=''>Select Option</option>\n\
<option value='1'>Input</option>\n\
<option value='2'>Text Field</option>\n\
<option value='3'>Dropdown</option>\n\</select>\n\
<br /> \n\
<div class='row ' style='display:none;' id='options'>\n\
<div class='form-group form-group-options col-xs-11 col-sm-8 col-md-12'>\n\
<div class='input-group input-group-option col-xs-12'>\n\
<input type='text' name='option["+(k+1)+"][]' class='form-control' placeholder='Type here' autocomplete='off'>\n\
<span class='input-group-addon input-group-addon-remove'>\n\
<span class='glyphicon glyphicon-remove'></span>\n\
</span>\n\
</div>\n\
</div>\n\
</div>\n\
<td id='require0'>\n\
<div>\n\
<center><label><input type='checkbox'id='versant_required' name= 'versant_examquestions_required["+(k+1)+"]' value='1'/> Required? </label></center> \n\
</div>\n\
</td>\n\
</td>");
$('#tab_logic').append('<tr id="addr'+(i+1)+'"></tr>');
i++;
k++;
});
$(document).on('change','[data-name="sel"] select',function(){
$(this).parent().find('div:first').show();
var type = $(this).val();
if(type == 3 || type == 4 ){
$(this).parent().find('div:first').show();
}else{
$(this).parent().find('div:first').hide();
}
});
//Delete Rows
$("#delete_row").click(function(){
if(i>1){
$("#addr"+(i-1)).html('');
i--;
}
});
//Focus dynamic
$(document).on('focus', 'div.form-group-options div.input-group-option:last-child input', function(){
var sInputGroupHtml = $(this).parent().html();
var sInputGroupClasses = $(this).parent().attr('class');
$(this).parent().parent().append('<div class="'+sInputGroupClasses+'">'+sInputGroupHtml+'</div>');
$('.input-group-addon.input-group-addon-remove').show();
$('.form-group-options').each(function(){
$(this).find('.input-group-addon.input-group-addon-remove:last').hide()
});
});
$(document).on('click', 'div.form-group-options .input-group-addon-remove', function(){
$(this).parent().remove();
});
});

increment radio button dynamically created in two different ways

I wanna create a radio button dynamically inside a table and i have done like this
<td colspan="3" class="table-info"><div class="ck">
<label><input type="radio" name="attendance[<?php echo $_SESSION['i']?>]" id="attendance[<?php echo $_SESSION['i']?>]" value="Yes">Yes</label> <label><input type="radio" name="attendance[<?php echo $_SESSION['i']?>]" id="attendance[<?php echo $_SESSION['i']?>]" value="No">No</label></td>
<?php $_SESSION['i']++; ?>
here is my javascript code this function will be called when a new row is added
var newRow = jQuery('<tr><td colspan="3"><label><input type="radio" name="attendance[<?php echo $_SESSION['i']?>]" id="attendance[<?php echo $_SESSION['i']?>]" value="Yes">Yes</label><label><input type="radio" name="attendance[<?php echo $_SESSION['i']?>]" id="attendance[<?php echo $_SESSION['i'];$_SESSION['i']++; ?>]" value="No">No</label></td></tr>');
counter++;
jQuery('table.table').append(newRow);
I want all the radio buttons to be stored in a single array.I have no idea how to do that someone help me to do this
Here is my entire code
<?php
session_start();
error_reporting(0);
?>
<?php include 'mqsqlconnection.php';
?>
<?php
mysql_select_db("training_db");
$sql = "SELECT trainer_name as tr_name FROM training_details";
$res = mysql_query($sql);
$trainer_name=mysql_result($res,0);
$sql1 = "SELECT training_name as trng_name FROM training_details";
$res1 = mysql_query($sql1);
$training_name=mysql_result($res1,0);
if ( isset ( $_POST['submit_details'] ) ) {
$trainer_name=$_POST["trainer_name"];
$training_name=$_POST["training_name"];
$training_date=$_POST["training_date"];
$from_time=$_POST["from_time"];
$to_time=$_POST["to_time"];
$venue=$_POST["venue"];
$ins="INSERT INTO training_info(trainer_name,training_name,training_date,from_time,to_time,venue)VALUES('$trainer_name','$training_name','$training_date','$from_time','$to_time','$venue')";
mysql_query($ins);
$sql12 = "SELECT training_id as tid FROM training_info WHERE trainer_name ='$trainer_name' and training_name='$training_name'";
$res12 = mysql_query($sql12);
$training_id=mysql_result($res12,0);
//echo $training_id;
echo $_SESSION['num1'];
$present=1;
$absent=0;
if(!empty($_POST['emp_code'])) {
$empcode=$_POST['emp_code'];
for($i=0;$i<sizeof($empcode);$i++)
{
$inssql="INSERT INTO training_attendance(tid,emp_code,attendance) VALUES ($training_id,$empcode[$i],0)";
mysql_query($inssql);
}
if(isset($_POST['attendance'])&&!empty($_POST['attendance'])) {
$ccount=$_POST['attendance'];
for($i=0;$i<sizeof($ccount);$i++)
{
$inssql23="update training_attendance set attendance=1 where emp_code=$ccount[$i] and tid=$training_id";
mysql_query($inssql23);
}
}
}
}
?>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<title>Training Attendance form</title>
<link rel="stylesheet" href="logincss.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>
<script src="js/bootstrap-checkbox.js"></script>
<script>
jQuery(function() {
var counter = 1;
jQuery('a.addrow').click(function(event) {
event.preventDefault();
var newRow = jQuery('<tr><td colspan="3" class="table-active"><input type="text" name="emp_code[]" id="emp_code[]" class="form-control"></td><td colspan="3" class="table-success"><input type="text" name="emp_name[]" id="emp_name[]" class="form-control"></td><td colspan="3" class="table-info"><input type="text" name="emp_mailid[]" id="emp_mailid[]" class="form-control"></td><td colspan="3" class="table-info"><input type="text" name="nomination[]" id="nomination[]" class="form-control"></td><td colspan="3"><label><input type="radio" name="attendance[<?php echo $_SESSION['i']?>]" id="attendance[<?php echo $_SESSION['i']?>]" value="Yes">Yes</label><label><input type="radio" name="attendance[<?php echo $_SESSION['i']?>]" id="attendance[<?php echo $_SESSION['i'];$_SESSION['i']++; ?>]" value="No">No</label></td></td><td></span></td></tr>');
counter++;<?php $i++; ?>
jQuery('table.table').append(newRow);
//Init bootstrapToggle
$('.toggleone').bootstrapToggle({
on: 'Yes',
off: 'No'
});
});
});
</script>
<script>
$(function(){
$(document).on('click', '.remove', function() {
var trIndex = $(this).closest("tr").index();
if(trIndex>1) {
$(this).closest("tr").remove();
} else {
alert("Sorry!! Can't remove first row!");
}
});
});
</script>
<script>
$(function() {
$('#toggleone').bootstrapToggle({
on: 'Enabled',
off: 'Disabled'
});
}) ​</script>
</head>
<body>
<div class="container">
<div class="row vertical">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title"><center>Training Attendance form</center></h3>
</div>
<div class="panel-body">
<form class="form-horizontal" action="" method="post" id="loginform"
enctype="multipart/form-data">
<div class="form-group">
<label for="input_trainername" class="col-sm-3 control-label">Trainer Name</label>
<div class="col-sm-8">
<input readonly class="form-control" id="trainer_name" name="trainer_name" value="<?php echo $trainer_name;?>">
</div>
</div>
<div class="form-group">
<label for="input_trainingname" class="col-sm-3 control-label">Training Name</label>
<div class="col-sm-8">
<input readonly class="form-control" id="training_name" name="training_name" value="<?php echo $training_name;?>">
</div>
</div>
<div class="form-group">
<label for="input_trainingname" class="col-sm-3 control-label">Date</label>
<div class="col-sm-8">
<input type="date" class="form-control" id="training_date" name="training_date" value="" onfocus="(this.type='date')" onfocusout="(this.type='text')">
</div>
</div>
<div class="form-group">
<label for="labeldate" class="col-sm-1 control-label">Time</label>
<label for="input_fromdate" class="col-sm-2 control-label">From</label>
<div class="col-sm-3">
<input type="time" class="form-control" id="from_time" name="from_time"
placeholder="Pick here">
</div>
<label for="input_todate" class="col-sm-1 control-label">To </label>
<div class="col-sm-3">
<input type="time" class="form-control" id="to_time" name="to_time" value=""
placeholder="Pick here" >
</div></div>
<div class="form-group">
<label for="input_venue" class="col-sm-3 control-label">Venue</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="venue" name="venue" value="">
</div>
</div>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<?php
//session_start();
//echo $_SESSION['year'];
//while ($row = mysql_fetch_array($result)) {
?>
<table align="center" class="table table-bordered"id="tb" border="10" bordercolor="#0066FF" style=\"background-color:#CCFFFF\" width="50%" cellpadding="9" cellspacing="9">
<tr><b>
<td colspan="3">Empid</td>
<td colspan="3">Name</td>
<td colspan="3">Email ID</td>
<td colspan="3">Nominated and invited</td>
<td colspan="3">Attendance</td>
<td><span class="glyphicon glyphicon-plus"></span></td>
</b></tr>
<?php mysql_select_db("training_db");
$result_s = mysql_query("select * from training_nominated");
$_SESSION['num1']=mysql_num_rows($result_s);
while($row = mysql_fetch_array($result_s))
{?><tr><td colspan="3" class="table-success"><div class="ck"><input readonly name="emp_name[]" id="emp_name[]" value="<?php echo $row['emp_code']?>"class="form-control"></td>
<td colspan="3" class="table-success"><div class="ck"><input readonly name="emp_name[]" id="emp_name[]" value="<?php echo $row['emp_name']?>"class="form-control"></td>
<td colspan="3" class="table-info"><div class="ck"><input readonly name="emp_mailid[]" id="emp_mailid[]" value="<?php echo $row['emp_mailid']?>"class="form-control"></td>
<td colspan="3" class="table-info"><div class="ck"><input readonly name="nomination[]" id="nomination[]" value="<?php echo $row['nomination']?>"class="form-control"></td>
<td colspan="3" class="table-info"><div class="ck">
<label><input type="radio" name="attendance[<?php echo $_SESSION['i']?>]" id="attendance[<?php echo $_SESSION['i']?>]" value="Yes">Yes</label> <label><input type="radio" name="attendance[<?php echo $_SESSION['i']?>]" id="attendance[<?php echo $_SESSION['i']?>]" value="No">No</label></td>
<td colspan="3" class="table-info">
<a href='javascript:void(0);' class='disabled'><span class='glyphicon glyphicon-remove'></span></a></td> </tr>
<?php $_SESSION['i']++; }?>
</table>
<!--<script>
$("#attendance").change(function(){
if($(this).prop("checked") == true){
alert("1");
}else{
alert("0");
}
});-->
<div class="form-group">
<div class="col-xs-11 text-center">
<button type="submit" class="btn btn-success" id="submit_details" name="submit_details">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
You should remember that PHP is executed server-side, and JavaScript is executed client-side. So whithin this line of code
var newRow = jQuery('[..]id="attendance[<?php echo $_SESSION['i'];$_SESSION['i']++; ?>]" value="[..]');
the $_SESSION['i']++ is executed only once at the time the server builds the response (the HTML), and not everytime that javascript-function is called.
So you should write an incrementer on a JavaScript-variable, instead of a PHP-variable.
Assuming you don't change this form with AJAX, I replaced the $_SESSION['i'] with a normal PHP-variable in the code below (as sessions will be an overkill):
<? $nextRowId = 0; ?>
[...]
<td colspan="3" class="table-info"><div class="ck">
<label><input type="radio" name="attendance[<?php echo $nextRowId ?>]" id="attendance[<?php echo $nextRowId ?>]" value="Yes">Yes</label> <label><input type="radio" name="attendance[<?php echo $nextRowId ?>]" id="attendance[<?php echo $nextRowId ?>]" value="No">No</label></td>
<?php $nextRowId++; ?>
[...]
<script type="text/javascript">
// Store PHP-variable-value of $nextRowId in a JS-variable
// Inspect your HTML source (F12 in the browser), this will simply be something like: var nextRowId = 1;
var nextRowId = <?php echo json_encode($nextRowId) ?>;
function addRow() {
// Use this JS-variable browser-side
var newRow = jQuery('<tr><td colspan="3"><label><input type="radio" name="attendance[' + nextRowId + ']" id="attendance[' + nextRowId + ']" value="Yes">Yes</label><label><input type="radio" name="attendance[' + nextRowId + ']" id="attendance[' + nextRowId + ']" value="No">No</label></td></tr>');
// Increment JS-variable
nextRowId++;
jQuery('table.table').append(newRow);
}
</script>
When you're only just printing 1 row in your initial HTML, this can be more simplified by skipping the PHP-variable $nextRowId:
<td colspan="3" class="table-info"><div class="ck">
<label><input type="radio" name="attendance[0]" id="attendance[0]" value="Yes">Yes</label> <label><input type="radio" name="attendance[0]" id="attendance[0]" value="No">No</label></td>
<script type="text/javascript">
var nextRowId = 1;
// And so on
Ya the above comment worked
but assigning
var nextRowId=($('#tb tr').length)-1;//(number of rows fetched from database)-(one header row)
instead of
var nextRowId = <?php echo json_encode($nextRowId) ?>;
as this created conflict for array indexes.It worked perfectly.

Who search a variable name with DOM?

I have this code and I need know how to use "nombre" variable to find data with DOM, this aplication works without Jquery.
window.onload = function(e){
<%if(!faltanCampos.equals("")){%>alert("<%=faltanCampos%>")<%}%>
//Ocultamos los vacios'
var j, nombre
i=<%=totalSig%>
for (j=i-1;j > 0;j--){
//nombre="txtsssiidenti" & j'
nombre="txtissicodtui" + j
if (document.frmDatos.nombre.value==""){
menos();
}
}
actualizaNivel();
}
Im translating the aplication from vb to js, the vb code:
Sub window_onload
<%if(!faltanCampos.equals("")){%>msgbox("<%=faltanCampos%>")<%}%>
'Ocultamos los vacios'
Dim j, nombre
i=<%=totalSig%>
for j=i-1 to 0 step -1
'nombre="txtsssiidenti" & j'
nombre="txtissicodtui" & j
if (document.all(nombre).value="") then
menos()
end if
next
actualizaNivel
End sub
FireBug error:
TypeError: document.frmDatos.nombre is undefined
HTML:
<title><%=GestorIdioma.getCadena("ARGES")%> - <%=GestorIdioma.getCadena("DESCRIARCHIVO")%></title>
</head>
<body onmouseover="defaultStatus='<%=GestorIdioma.getCadena("PIEPAGINA")%>'; return true;" >
<iframe name="frameResultado" id="frameResultado" width="0" height="0" src=""></iframe>
<!-- Menu -->
<%# include file="../includeJSP/body_sitemap.inc" %>
<%# include file="../includeJSP/camino.inc" %>
<%if(!Utilidades.dameElemHashtable(h,"EXPURGO").equals("S") && !Utilidades.dameElemHashtable(h,"TRANSFERENCIA").equals("S")){%>
<!-- Opciones auxiliares -->
<%# include file="../includeJSP/OpcionesMant.inc" %>
<%}%>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="175" valign="top">
<form name="frmDatos" method="post" action="">
<!-- Los siguientes campos, aunque no aparecen en esta pestaña, los almacenamos aquí (ya que se heredan) -->
<input type="hidden" name="apartado" value="<%=apartado%>"/>
<input type="hidden" name="hacer" value="<%=hacer%>"/>
<input type="hidden" name="acceso" value="<%=acceso%>"/>
<input type="hidden" name="totalSig" value="<%=totalSig%>"/>
<input type="hidden" name="destino" value="signatura"/>
<input type="hidden" name="txtpsarcodarc" value="<%=Utilidades.dameElemHashtable(hotros,"txtpsarcodarc")%>"/>
<input type="hidden" name="txtpsarcodarcold" value="<%=Utilidades.dameElemHashtable(hotros,"txtpsarcodarcold")%>"/>
<input type="hidden" name="txtisarcodpro" value="<%=Utilidades.dameElemHashtable(hotros,"txtisarcodpro")%>"/>
<input type="hidden" name="masCodNivelA" value="<%=Utilidades.dameElemHashtable(h,"masCodNivelA")%>"/>
<input type="hidden" name="nivelArchivoAnterior" value="<%=Utilidades.dameElemHashtable(h,"masCodNivelA")%>"/>
<!-- Navegación Lateral -->
<%# include file="../includeJSP/NavegaArea.inc" %>
</td>
<td valign="top">
<p class="filareas">
<span class="cmpeti"><%=GestorIdioma.getCadena("SIGNATURA")%></span>
</p>
<div class="grisclaro">
<p class="filacmp">
<span class="inpuazul"><%= GestorIdioma.getCadena("TITULO")%>: </span>
<span class="cmpeti"><%=Utilidades.dameElemHashtable(hotros,"txtssartitulo",session.getAttribute("s54b.varidioma").toString())%></span>
</p>
<%if(Utilidades.dameElemHashtable(h,"TRANSFERENCIA").equals("S")){%>
<div class="grisclaro">
<p class="filacmp">
<span class="cmpeti"><%=GestorIdioma.getCadena("ENTRANSFERENCIA")%></span>
</p>
</div>
<%}
if(Utilidades.dameElemHashtable(h,"EXPURGO").equals("S")){%>
<div class="grisclaro">
<p class="filacmp">
<span class="cmpeti"><%=GestorIdioma.getCadena("ENEXPURGO")%></span>
</p>
</div>
<%}%>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr id="trnivelArchivo">
<td valign="top" colspan="2">
<p class="filacmp">
<span class="inpuazul"><%=GestorIdioma.getCadena("NIVELARCHIVO")%>:</span>
<select name="cboNivelA" class="inpuedi" onchange="javascrip:actualizaNivel()" <%=habilitado%> >
<% boolean carga=false;
anterior=(!Utilidades.dameElemHashtable(h,"masCodNivelA").equals("")?Utilidades.dameElemHashtable(h,"masCodNivelA").toString():"");
if(lnivelAr!=null){
for(i=0;i<lnivelAr.size();i++){
carga=false;
hvalores = (Hashtable)lnivelAr.get(i);
//Comprobamos permisos
if(hvalores.get("RECODRAR").equals("10") && per.damePermiso("MARO",request,response)){
carga=true;
}else if(hvalores.get("RECODRAR").equals("20") && per.damePermiso("MARD",request,response)){
carga=true;
}else if(hvalores.get("RECODRAR").equals("30") && per.damePermiso("MARG",request,response)){
carga=true;
}else if(hvalores.get("RECODRAR").equals("40") && per.damePermiso("MARH",request,response)){
carga=true;
}else if(hvalores.get("RECODRAR").equals("25") && per.damePermiso("MARC",request,response)){
carga=true;
}
if(carga){
if(hvalores.get("RECODRAR").equals(anterior)){
%>
<option class="inpuedi" value="<%=hvalores.get("RECODRAR")%>" selected="selected"><%=hvalores.get("REDESCRI")%></option>
<% }else{%>
<option class="inpuedi" value="<%=hvalores.get("RECODRAR")%>"><%=hvalores.get("REDESCRI")%></option>
<% }
}
}
}else{%>
<option class="inpuedi" value="" selected> </option>
<% }%>
</select>
</p>
</td></tr>
<%
String letras = "";
int numero = 0;
if(lclavesUI!=null){
for(i=0;i<lclavesUI.size();i++){
hvalores= new Hashtable();
hvalores = (Hashtable)lclavesUI.get(i);
letras = Utilidades.dameElemHashtable(hvalores,"letras");
numero = Utilidades.esNumero(Utilidades.dameElemHashtable(hvalores,"numero"))?Integer.parseInt(Utilidades.dameElemHashtable(hvalores,"numero")):0;
}
}
for(j=0;j<Integer.parseInt(totalSig);j++){
//Si no hay SIIDENTI, ponemos una por defecto
if(Utilidades.dameElemHashtable(h,"txtsssiidenti" + j).equals("")) {
numero++;
h.put("txtsssiidenti" + j,Utilidades.formateaNumCaja(letras,numero,true));
}
%>
<tr id="tipoUI<%=j%>"><td valign="top">
<hr/>
<input type="hidden" name="masUIvalida<%=j%>" value="<%=Utilidades.dameElemHashtable(h,"masUIvalida" + j).equals("")?"S":Utilidades.dameElemHashtable(h,"masUIvalida" + j)%>"/>
<input type="hidden" name="masUIdeposito<%=j%>" value="<%=Utilidades.dameElemHashtable(h,"masUIdeposito" + j)%>"/>
<input type="hidden" name="txtissicodtui<%=j%>" value="<%=Utilidades.dameElemHashtable(h,"txtissicodtui" + j)%>"/>
<input type="hidden" name="masUnDescri<%=j%>" value="<%=Utilidades.dameElemHashtable(h,"masUnDescri" + j)%>"/>
<input type="hidden" name="masUnMetros<%=j%>" value="<%=Utilidades.dameElemHashtable(h,"masUnMetros" + j)%>"/>
<p class="filacmp">
<span class="cmpeti"><%=GestorIdioma.getCadena("TIPOUI")%>:</span>
<select name="cboTipoUI<%=j%>" class="inpuedi" onchange="javascript:actualizaTipo('<%=j%>')" <%=habilitado%> >
<option class="inpuedi" value="" selected="selected"> </option>
<%anterior=Utilidades.dameElemHashtable(h,"txtissicodtui" + j);
if(ltipoui!=null){
for(i=0;i<ltipoui.size();i++){
hvalores = (Hashtable)ltipoui.get(i);
if(hvalores.get("UNCODTUI").equals(anterior)){
%>
<option class="inpuedi" value="<%=hvalores.get("UNCODTUI")%>~<%=Utilidades.dameElemHashtable(hvalores,"UNMETROS")%>" selected="selected"><%=hvalores.get("UNDESCRI")%> - <%if ((Utilidades.dameElemHashtable(hvalores,"UNMETROS").substring(0,1)).equals(".")) {%>0<%=Utilidades.dameElemHashtable(hvalores,"UNMETROS").replace('.',',')%><%}else{%><%=Utilidades.dameElemHashtable(hvalores,"UNMETROS").replace('.',',')%><%}%> m.</option>
<% }else{%>
<option class="inpuedi" value="<%=hvalores.get("UNCODTUI")%>~<%=Utilidades.dameElemHashtable(hvalores,"UNMETROS")%>"><%=hvalores.get("UNDESCRI")%> - <%if ((Utilidades.dameElemHashtable(hvalores,"UNMETROS").substring(0,1)).equals(".")) {%>0<%=Utilidades.dameElemHashtable(hvalores,"UNMETROS").replace('.',',')%><%}else{%><%=Utilidades.dameElemHashtable(hvalores,"UNMETROS").replace('.',',')%><%}%> m.</option>
<% }
}
}else{%>
<option class="inpuedi" value="" selected="selected"> </option>
<% }%>
</select>
- <span class="cmpeti"><%=GestorIdioma.getCadena("IDENCAJA")%>:</span>
<input type="text" class="inpuedi" name="txtsssiidenti<%=j%>" size="30" value="<%=Utilidades.formateaNumCaja(Utilidades.dameElemHashtable(h,"txtsssiidenti" + j),0,true, "mostrar")%>" maxlength="15" onblur="javascript:formateaUI(this,'<%=GestorIdioma.getCadena("FORMATOUI")%>');" <%=soloLectura%>/>
</p>
</td>
<td valign="top" align="right">
<hr/>
<p class="filacmp">
<%if(!Utilidades.dameElemHashtable(h,"EXPURGO").equals("S") && !Utilidades.dameElemHashtable(h,"TRANSFERENCIA").equals("S")){%>
<input type="button" name="btnBorrar" class="boton" value="<%=GestorIdioma.getCadena("BORRAR")%>" onclick="javascript:BorraDatos('<%=j%>');"/>
<%}%>
</p>
</td>
</tr>
<tr id="iden<%=j%>"><td valign="top" colspan="2">
<p class="filacmp">
<span class="cmpeti"><%=GestorIdioma.getCadena("IDENEXPUI")%>:</span>
<input type="text" class="inpuedi" name="txtsssiexpide<%=j%>" size="10" value="<%=Utilidades.dameElemHashtable(h,"txtsssiexpide" + j)%>" maxlength="3" onKeyPress="javascript:funValidarNumero();" onblur="javascript:formateaNumero(this);" <%=soloLectura%> />
</p>
</td></tr>
<tr id="deposito<%=j%>"><td valign="top" colspan="2">
<input type="hidden" name="txtissicodrsg<%=j%>" value="<%=Utilidades.dameElemHashtable(h,"txtissicodrsg" + j)%>"/>
<input type="hidden" name="mastamdep<%=j%>" value="<%=Utilidades.dameElemHashtable(h,"mastamdep" + j)%>"/>
<input type="hidden" name="masgesaut<%=j%>" value="<%=Utilidades.dameElemHashtable(h,"masgesaut" + j)%>"/>
<p class="filacmp">
<span class="cmpeti"><%=GestorIdioma.getCadena("DEPOSITO")%>:</span>
<input type="text" class="inpuedi" name="masDBreve<%=j%>" size="30" value="<%=encodeHTML(Utilidades.dameElemHashtable(h,"masDBreve" + j))%>" readonly="readonly"/>
<input type="text" class="inpuedi" name="masDDescri<%=j%>" size="40" value="<%=encodeHTML(Utilidades.dameElemHashtable(h,"masDDescri" + j))%>" readonly="readonly"/>
<%if(!Utilidades.dameElemHashtable(h,"EXPURGO").equals("S") && !Utilidades.dameElemHashtable(h,"TRANSFERENCIA").equals("S")){%>
<input type="button" name="btnCodClas" class="boton" value="..." onclick="javascript:SelDepconEspacio('DISPONIBILIDAD',document.frmDatos.txtissicodrsg<%=j%>.value,'<%=j%>')" />
<input type="button" name="btnCodClasT" class="boton" value="<%=GestorIdioma.getCadena("TODOS")%>" onclick="javascript:SeleccionarComponente('DISPONIBILIDAD',document.frmDatos.txtissicodrsg<%=j%>.value,'<%=j%>')"/>
<%}%>
</p>
</td>
</tr>
<tr id="idendeposito<%=j%>"><td valign="top" colspan="2">
<p class="filacmp">
<span class="cmpeti"><%=GestorIdioma.getCadena("CODUBICACION")%>:</span>
<input type="text" class="inpuedi" name="txtsnsirsgide<%=j%>" size="30" value="<%=Utilidades.dameElemHashtable(h,"txtsnsirsgide" + j)%>" <%=soloLectura%>/>
</p>
</td></tr>
<tr id="obser<%=j%>"><td valign="top" colspan="2">
<p class="filacmp">
<span class="cmpeti"><%=GestorIdioma.getCadena("OBSERVACIONES")%>:</span><br />
<textarea name="txtsnsiobserv<%=j%>" rows="4" cols="65" <%=soloLectura%> ><%=Utilidades.dameElemHashtable(h,"txtsnsiobserv" + j)%></textarea>
</p>
<div class="grisclaro bordeuskera" >
<p class="filareas">
<span class="cmpeti"><%=GestorIdioma.getCadena("SIGNATURA")%></span> <span class="cmpetirojo">*<%=GestorIdioma.getCadena("DATOSEUSKERA")%></span>
</p>
<div class="grisclaro">
<p class="filacmp">
<span class="cmpeti"><%=GestorIdioma.getCadena("OBSERVACIONES")%>:</span><br />
<textarea name="txtsnsiobserv<%=j%>_e" rows="4" cols="65" <%=soloLectura%> ><%=Utilidades.dameElemHashtable(h,"txtsnsiobserv" + j+"_e")%></textarea>
</p>
</div>
</div>
</td></tr>
<%}%>
</table>
</div>
</td></tr>
</table>
<%if(!Utilidades.dameElemHashtable(h,"EXPURGO").equals("S") && !Utilidades.dameElemHashtable(h,"TRANSFERENCIA").equals("S")){%>
<!-- Opciones auxiliares -->
<%# include file="../includeJSP/OpcionesMant.inc" %>
<%}%>
</form>
</body>
</html>
Finally i found a solution
window.onload = function(e){
<%if(!faltanCampos.equals("")){%>alert("<%=faltanCampos%>")<%}%>
//Ocultamos los vacios'
var j, nombre
i=<%=totalSig%>
for (j=i-1;j > 0;j--){
nombre="txtissicodtui" + j
if ( document.getElementsByName(nombre)[0].value == ""){
menos();
}
}
actualizaNivel();
}

How to make an html dropdown work with PHP post?

I just modified my php file switching from a text box from one of my fields to a dropdown list and it no longer returns the "sexo" field in the output. Can someone tell me why this is? All I did was switch from a text box to a list.
It won't return all of the results it will only return the values from all columns except the sexo column which should be either Masculino or Femenino
The error I'm guessing has to be in the form or in the POST variable for "sexo"
<?php
include_once 'includes/db_connect.php';
include_once 'includes/functions.php';
sec_session_start();
if(!isset($_SESSION['username'])) {
header("Location: index.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1" />
<link rel="stylesheet" href="datepicker.css" type="text/css" />
<link rel="stylesheet" href="demo.css" type="text/css" />
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="datepicker.js"></script>
<script type="text/javascript" src="ValidarDatos.js"></script>
<title>Consulta niño Coprodeli Intranet</title>
</head>
<body>
<div id="content">
<div id="logo"> <img src="images/logo.jpg" /> </div>
<ul id="menu">
<li>Home</li>
<li>Niños</li>
<li>Padrinos</li>
<li>Centros</li>
<li>Informes</li>
<li>Usuarios</li>
<li>Salir</li>
</ul>
<div id="intro2">
<h1>Intranet Coprodeli</h1>
<p>Apadrinamiento y Programa<br />
de Niños en Alto Riesgo</p>
<div id="login">
</div>
</div>
<div id="right2">
<h4 class="migas">Estás en: Inicio | Consulta de niños</h4>
<br />
<?php
$output = NULL;
if(isset($_POST['submit'])){
// Connect to the database
$mysqli = NEW MySQLi("localhost","root","","coprodeli");
$nino_id = $mysqli->real_escape_string( $_POST['nino_id']);
$nombre = $mysqli->real_escape_string( $_POST['nombre']);
$apellidos = $mysqli->real_escape_string( $_POST['apellidos']);
$sexo = $mysqli->real_escape_string( $_POST['sexo']);
$estado = $mysqli->real_escape_string( $_POST['estado']);
$fecha_de_nacimiento_desde = $mysqli->real_escape_string( $_POST['fecha_de_nacimiento_desde']);
$fecha_de_nacimiento_hasta = $mysqli->real_escape_string( $_POST['fecha_de_nacimiento_hasta']);
$tipo_de_centro = $mysqli->real_escape_string( $_POST['tipo_de_centro']);
$nombre_del_centro = $mysqli->real_escape_string( $_POST['nombre_del_centro']);
$region_del_centro = $mysqli->real_escape_string( $_POST['region_del_centro']);
$nivel_de_estudio = $mysqli->real_escape_string( $_POST['nivel_de_estudio']);
$entrada_desde = $mysqli->real_escape_string( $_POST['entrada_desde']);
$entrada_hasta = $mysqli->real_escape_string( $_POST['entrada_hasta']);
$egreso_desde = $mysqli->real_escape_string( $_POST['egreso_desde']);
$egreso_hasta = $mysqli->real_escape_string( $_POST['egreso_hasta']);
//Query the database
$resultSet = $mysqli->query("SELECT nino_id, nombre, apellidos, sexo, estado, fecha_de_nacimiento_desde, fecha_de_nacimiento_hasta,
tipo_de_centro, nombre_del_centro, region_del_centro, nivel_de_estudio, entrada_desde, entrada_hasta, egreso_desde, egreso_hasta FROM nino
WHERE nino_id = '$nino_id' AND nombre = '$nombre' AND apellidos = '$apellidos' AND sexo = '$sexo' AND estado = '$estado' AND fecha_de_nacimiento_desde = '$fecha_de_nacimiento_desde'
AND fecha_de_nacimiento_hasta = '$fecha_de_nacimiento_hasta' AND tipo_de_centro = '$tipo_de_centro' AND nombre_del_centro = '$nombre_del_centro' AND
region_del_centro = '$region_del_centro' AND nivel_de_estudio = '$nivel_de_estudio' AND entrada_desde = '$entrada_desde' AND entrada_hasta = '$entrada_hasta'
AND egreso_desde = '$egreso_desde' AND egreso_hasta = '$egreso_hasta';" ) ;
// Edited on 9/7/2015 12:39PM by Anthony Sawah. I changed it from " if($resultSet['num_rows'] > 0) { " to " if($resultSet->num_rows > 0) {"
if($resultSet->num_rows > 0) {
while($rows = $resultSet->fetch_assoc())
{
$nino_id = $rows['nino_id'];
$nombre = $rows['nombre'];
$apellidos = $rows['apellidos'];
$sexo = $rows['sexo'];
$estado = $rows['estado'];
$fecha_de_nacimiento_desde = $rows['fecha_de_nacimiento_desde'];
$fecha_de_nacimiento_hasta = $rows['fecha_de_nacimiento_hasta'];
$tipo_de_centro = $rows['tipo_de_centro'];
$nombre_del_centro = $rows['nombre_del_centro'];
$region_del_centro = $rows['region_del_centro'];
$nivel_de_estudio = $rows['nivel_de_estudio'];
$entrada_desde = $rows['entrada_desde'];
$entrada_hasta = $rows['entrada_hasta'];
$egreso_desde = $rows['egreso_desde'];
$egreso_hasta = $rows['egreso_hasta'];
$output .= "<tr><td>".$estado."</td><td>".$nino_id."</td><td>".$apellidos."</td><td>".$nombre."</td><td>".$egreso_desde."</td><td>".$egreso_hasta."</td>";
}
}else{
$output = "No results";
}
}
?>
<fieldset class="required">
<legend>Consulta de niños:</legend>
<form method ="POST">
<p>ID niño: <input type="text" name="nino_id" />
<br> </br>
Nombre: <input type="text" name="nombre" />
<br> </br>
Apellidos: <input type="text" name="apellidos" /> <br> </br>
Sexo:
<select name="sexo">
<option value=""> Select...</option>
<option value="Masculino">Masculino</option>
<option value="Femenino">Femenino</option>
</select>
<br>
</br>
Estado: <input type="text" name="estado" /> <br> </br>
Fecha de
nacimiento desde
(DD-MM-YYYY): <input type="text" name="fecha_de_nacimiento_desde" /> <br> </br>
Fecha de
nacimiento hasta
(DD-MM-YYYY): <input type="text" name="fecha_de_nacimiento_hasta" /> <br> </br>
Tipo de centro: <input type="text" name="tipo_de_centro" /> <br> </br>
Nombre Del Centro: <input type="text" name="nombre_del_centro" /> <br> </br>
Región del Centro: <input type="text" name="region_del_centro" /> <br> </br>
Nivel de estudio: <input type="text" name="nivel_de_estudio" /> <br> </br>
Entrada desde
(DD-MM-YYYY): <input type="text" name="entrada_desde" /> <br> </br>
Entrada hasta
(DD-MM-YYYY): <input type="text" name="entrada_hasta" /> <br> </br>
Egreso desde
(DD-MM-YYYY): <input type="text" name="egreso_desde" /> <br> </br>
Egreso hasta
(DD-MM-YYYY): <input type="text" name="egreso_hasta" /> <br> </br>
<input type="submit" name="submit" value="Search" />
</p>
</form>
</fieldset>
<fieldset id="" class="required">
<legend>Resultado de la búsqueda:</legend>
<form id="form7" name="ResultadoBusqueda" action="ConsultarDetalleNino.php" enctype="multipart/form-data" method="post" >
<table>
<tr>
<td class="especial" width="11"></td>
<td colspan="6" class="especial"> </td>
</tr>
<tr>
<th></th>
<th width="15"></th>
<th width="88">Estado</th>
<th width="104">ID ninos </th>
<th width="234">Apellidos</th>
<th width="81">Nombre</th>
<th width="128">Fecha Ingreso</th>
<th width="106">Fecha Egreso</th>
</tr>
<?php echo $output;?>
</table>
<div class="actions">
<input name="ConsultarDetalleNino" type="submit" class="primaryAction" id="submit-" value="Consultar Detalle">
<input name="Cancelar" type="submit" class="primaryAction" id="submit-" value="Cancelar">
</div>
</form>
<form id="ListadoNinos" name="ListadoNinos" action="InformeNinos.php" method="post" target="_blank"></form>
</fieldset>
<div style="clear: both"></div>
</div>
<div id="footer">
<div id="col1">
<p> <br />
© </p>
</div>
<div id="col2">
<p>Info:<strong></strong><br />
Info2: <strong>completar</strong></p>
</div>
<div id="col3">
<p>
</div>
</div>
</div>
</body>
</html>
The reason being is because $sexo isn't included in your echo'd $output .= variables.
NOTA: There are other variables in your loop that are not part of the echo'd output, so make sure to add those if you want them to be echo'd also.

Categories