12-21-2016, 06:06 PM
Hy, thanks for the reply so fast. Im sorry, but I did not expressed correctly, (
I have two tables, first go perfect to add to the database, but the second I want to insert together the first table, Multiple INSERT tabels.
Ferst tabel: task
<pre></pre>
Form:
<pre></pre>
here it goes well. I want to do multiple insert
Second tabel: task_list_sub
form:
<pre></pre>
Here very well good, I get users from my DB, but I want to insert the form (task_list_sub) in the database with the same query from, task.
I have two tables, first go perfect to add to the database, but the second I want to insert together the first table, Multiple INSERT tabels.
Ferst tabel: task
<pre>
Code:
If(isset($_POST['submit'])){
// prepare sql and bind parameters
$cine_post_task = $_POST['cine_post_task'];
$utilizator = $_POST['utilizator'];
$titlu = $_POST['titlu'];
$color = $_POST['color'];
$descriere = $_POST['descriere'];
$data_start = $_POST['data_start'];
$data_end = $_POST['data_end'];
$post_data = $_POST['post_data'];
$post_time = $_POST['post_time'];
$q = "INSERT INTO task (cine_post_task, utilizator, titlu, color, descriere, data_start, data_end, post_data, post_time )
VALUES (
:cine_post_task ,
:utilizator ,
:titlu,
:color ,
:descriere ,
:data_start ,
:data_end ,
:post_data ,
:post_time
)";
$query = $odb->prepare($q);
$results = $query->execute(array(
":cine_post_task" => $cine_post_task ,
":utilizator" => $utilizator ,
":titlu" => $titlu,
":color" => $color ,
":descriere" => $descriere ,
":data_start" => $data_start ,
":data_end" => $data_end ,
":post_data" => $post_data ,
":post_time" => $post_time
));
header('Location: account.php');
}
Form:
<pre>
Code:
<form id="demo-form2" class="form-horizontal form-label-left " action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" id="payment-form">
<br>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Utilizator <span class="required"></span></label>
<div class="col-md-7 col-sm-7 col-xs-12">
<select id="utilizator" name="utilizator" class="select2_single form-control" required="required" tabindex="-1">
<option ></option>
<?php
foreach ($departamentCS as $permOp){
echo "<option value='$permOp->lname'>$permOp->lname</option>";
}
?>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Titlu <span class="required">*</span>
</label>
<div class="col-md-7 col-sm-7 col-xs-12">
<input type="text" id="titlu" name="titlu" required="required" class="form-control col-md-7 col-xs-12">
<input type="hidden" id="last-name" name="cine_post_task" required="required" value="<?=ucfirst($user->data()->lname)?>" class="form-control col-md-7 col-xs-12">
<input name="post_time" id='time' type="hidden" value="" />
<input name="post_data" id='' type="hidden" value="<?php echo date("d/m/Y");?>" />
<script>
function startTime() {
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
h = checkTime(h);
m = checkTime(m);
s= checkTime(s);
document.getElementById('time').value = h+":"+m+":"+s;
var t = setTimeout(function(){startTime()},1000);
}
function checkTime(i) {
if (i<10) {i = "0" + i} // add zero in front of numbers < 10
return i;
}
startTime();
</script>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Data start <span class="required">*</span>
</label>
<div class="col-md-7 col-sm-7 col-xs-12">
<input type="text" name="data_start" class="form-control has-feedback-left" required="required" id="single_cal2" value="<?php echo date("d/m/Y");?>" placeholder="First Name" aria-describedby="inputSuccess2Status2">
<span class="fa fa-calendar-o form-control-feedback left" aria-hidden="true"></span>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Data end <span class="required">*</span>
</label>
<div class="col-md-7 col-sm-7 col-xs-12">
<input type="text" name="data_end" class="form-control has-feedback-left" required="required" id="single_cal3" placeholder="First Name" aria-describedby="inputSuccess2Status2">
<span class="fa fa-calendar-o form-control-feedback left" aria-hidden="true"></span>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Detalii<span class="required"></span>
</label>
<div class="col-md-7 col-sm-7 col-xs-12">
<textarea id="message" required="required" class="form-control" name="descriere" data-parsley-trigger="keyup" data-parsley-minlength="20" data-parsley-maxlength="100" data-parsley-minlength-message="Trebui sa pui celputin 20 caractere"
data-parsley-validation-threshold="10"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Culoare <span class="required"></span>
</label>
<div class="col-md-7 col-sm-7 col-xs-12">
<select class="colorpicker-selectColor-unknown" id="color" name="color">
<option value="#000000">Black</option>
<option value="#7bd148">Green</option>
<option value="#5484ed">Bold blue</option>
<option value="#a4bdfc">Blue</option>
<option value="#46d6db">Turquoise</option>
<option value="#7ae7bf">Light green</option>
<option value="#51b749">Bold green</option>
<option value="#fbd75b">Yellow</option>
<option value="#ffb878">Orange</option>
<option value="#ff887c">Red</option>
<option value="#dc2127">Bold red</option>
<option value="#dbadff">Purple</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Fisiere<span class="required"></span>
</label>
<input type="file" class="filestyle" data-icon="false">
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Securitate<span class="required"></span>
</label>
<input type="checkbox" required="required" id="checkbox1" />
</div>
here it goes well. I want to do multiple insert
Second tabel: task_list_sub
form:
<pre>
Code:
<div class="container">
<div class="row">
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<input type="search" class="form-control" id="search" placeholder="Add your options..">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="searchable-container">
<?php
//Cycle through users
foreach ($departamentCS as $permOp){
echo "
<div class='items col-xs-5 col-sm-5 col-md-3 col-lg-3'>
<div class='info-block block-info clearfix'>
<div data-toggle='buttons' class='btn-group bizmoduleselect'>
<label class='btn btn-default'>
<div class='bizcontent'>
<input type='checkbox' name='var_id[]' autocomplete='off' value=''>
<span class='glyphicon glyphicon-ok glyphicon-lg'></span>
<h5>$permOp->lname</h5>
</div>
</label>
</div>
</div>
</div>";
} ?>
</div>
</div><br>
</div><br>
</div>
<input type="hidden" id="utilizatorr" name="utilizatorr" value="">
<input type="hidden" id="titlu_sub" name="titlu_sub" value="">
<input type="hidden" id="time_start" name="time_start" value="">
<input type="hidden" id="time_end" name="time_end" value="">
<input type="hidden" id="colorr" name="color_sub" value="">
<textarea id="messageee" required="required" class="form-control" name="messageee" data-parsley-trigger="keyup" data-parsley-minlength="20" data-parsley-maxlength="100" data-parsley-minlength-message="Trebui sa pui celputin 20 caractere"
data-parsley-validation-threshold="10"></textarea>
</div>
Here very well good, I get users from my DB, but I want to insert the form (task_list_sub) in the database with the same query from, task.