I am having an undefined index error While Executing the following code.
I have fetched data on run time in form from database table tbl_usr_training_master, i want to add this table fields into another table with the name tbl_usr_training_master2. Also i am getting first table ID on runtime using $_GET method from another page. The following code is not working as per i desire, your help is much more appericiated
Following is the PHP Code, i have tried both methods, 1. INSERT INTO and 2. UPDATE Table.
$eid = $_GET['rid'];
$query = "Select * from tbl_usr_training_master where trai_master_id = '$eid';";
$rs = mysqli_query($con, $query);
$row = mysqli_fetch_array($rs);
$trainingID = $row['trai_master_id']; //Tbl_usr_training_master PRIMARY KEY ID
$TrainerName = $row['trai_name'];
$TrainerExp = $row['trai_expertise'];
$TrainingTitle = $row ['tari_program_title'];
$TrainingDate = $row['trai_date'];
$TrainingDays = $row['t_days'];
$TrainingVenue = $row['Venue'];
$TrainingCity = $row['City'];
$TrainingPartOrg = $row ['trai_partner_organization'];
$TrainingCat = $row['trai_type_cata'];
$TrainingSubCat = $row['trai_type_subcata'];
if(isset($_POST['ButtonPost']))
{
//$TrainerName="";
$trainingID = $_POST['id']; //Tbl_usr_training_master PRIMARY KEY ID
$Trainer_Name = $_POST['trainer_name'];
$TrainerExp = $_POST['TrainerExp'];
$TrainingTitle = $_POST['Trainingtitle'];
$TrainingDate = $_POST['TrainingDate'];
$TrainingDays = $_POST['TrainingDays'];
$TrainingVenue = $_POST['Venue'];
$TrainingCity = $_POST['City'];
$TrainingPartOrg = $_POST['PartnerOrg'];
$TrainingCat = $_POST['TrainingCat'];
$TrainingSubCat = $_POST['traningsubcat'];
$query = "INSERT INTO tbl_usr_training_master2
(trai_master_id, trai_name,trai_expertise,tari_program_title,trai_date,t_days,Venue,City,trai_partner_organization,trai_type_cata, trai_type_subcata)
VALUES
('$trainingID','$TrainerName','$TrainerExp','$TrainingTitle','$TrainingDate','$TrainingDays','$TrainingVenue','$TrainingCity',
'$TrainingPartOrg','$TrainingCat','$TrainingSubCat');";
/* $query = "UPDATE tbl_usr_training_master2 SET
trai_master_id = '$trainingID',
trai_name = '$Trainer_Name',
trai_expertise = '$TrainerExp',
tari_program_title = '$TrainingTitle',
trai_date = '$TrainingDate',
t_days = '$TrainingDays',
trai_date = '$TrainingDate',
Venue = '$TrainingVenue',
City = '$TrainingCity',
trai_partner_organization = '$TrainingPartOrg',
trai_type_cata = '$TrainingCat',
trai_type_subcata = '$TrainingSubCat'
WHERE trai_master_id='$trainingID'"; */
$rs = mysqli_query($con, $query);
}
$result = mysqli_multi_query($con, $query);
if ($result != 1)
{
//die(mysqli_error($con));
echo "Error: " . $query . "<br>" . mysqli_error($con);
}
My HTML Code i want to get values and INSERT into table
<form role="form" name="frmreg" id="frmreg" action="" method="post" onclick="validate();" enctype="multipart/form-data">
<div align="center">
<table class="table table-bordered" width="108%" height="162" border="1" align="center">
<tr>
<th colspan="4" scope="row" bgcolor="#999999"><div align="center">Post Event Budget Form <br />
</div></th>
</tr>
<tr>
<th scope="row" style="font-size:10px" align="left">Pre Budget Event Form ID</th>
<th colspan="3" align="left" bgcolor="#B8D8D8" style="font-size:10px" scope="row">
<input type="text" required="required" Value="<?php echo $trainingID;?>" name="id" id="id" disabled>
</th>
</tr>
<tr>
<th width="74" scope="row" style="font-size:10px" align="left">Training Program / Event Title</th>
<th colspan="3" scope="row" bgcolor="#B8D8D8" align="left">
<input type="text" required="required" Value="<?php echo $TrainingTitle;?>" placeholder='"TOPIC"' name="Trainingtitle" id="Trainingtitle" width="auto" disabled/>
</th>
</tr>
<tr>
<th scope="row" style="font-size:10px" align="left">Trainer Experties</th>
<th colspan="3" align="left" bgcolor="#B8D8D8" style="font-size:10px" scope="row">
<select name="TrainerExp" class="form-control" required="required" required = "required" id="TrainerExp" disabled >
<option selected ><?php echo $TrainerExp;?></option>
<option value="Yes">Export</option>
<option value="Yes">MBA Marketing</option>
<option value="Yes">Phd Computer Sciences</option>
</select>
</th>
</tr>
<tr>
<th scope="row" style="font-size:10px" align="left">Trainer Name</th>
<th colspan="3" align="left" bgcolor="#B8D8D8" style="font-size:10px" scope="row">
<select name="trainer_name" class="form-control" required = "required" id="trainer_name" disabled >
<option selected value="<?php echo $TrainerName;?>"> <?php echo $TrainerName;?></option>
<option value="Yes">Ali</option>
<option value="No">Aslam</option>
<option value="No">Iqbal</option>
</select>
</th>
</tr>
<tr>
<th scope="row" style="font-size:10px" align="left">Date of the Event</th>
<th width="179" bgcolor="#B8D8D8" scope="row">
<input type="date" required="required" Value="<?php echo $TrainingDate;?>" name="TrainingDate" id="TrainingDate" disabled /></th>
<th width="327" scope="row" style="font-size:10px" align="center">Event Duration (Days)</th>
<th width="457" bgcolor="#B8D8D8" scope="row">
<input type="number" required="required" Value="<?php echo $TrainingDays;?>" name="TrainingDays" id="TrainingDays" disabled/>
</th>
</tr>
<tr>
<th scope="row" style="font-size:10px" align="left">Training Categoery</th>
<th colspan="3" align="left" bgcolor="#B8D8D8" style="font-size:10px" scope="row">
<select name="TrainingCat" class="form-control" Value="<?php echo $TrainingCat;?>" required = "required" id="TrainingCat" disabled >
<option selected disabled>Post Budget Form</option>
</select>
</th>
</tr>
<tr>
<th scope="row" style="font-size:10px" align="left">Training Subcatagoery</th>
<th colspan="3" align="left" bgcolor="#B8D8D8" style="font-size:10px" scope="row">
<select name="traningsubcat" class="form-control" required = "required" id="traningsubcat" >
<option selected value="<?php echo $TrainingSubCat;?>" disabled><?php echo $TrainingSubCat;?></option>
<!--<option disabled>Select Options</option>
<option value="No" disabled>In House Training </option>
<option value="No" disabled>YEP</option>
<option value="No" disabled>T-Desk Inhouse</option>
<option value="No" disabled>T-Desk Outsource</option>
<option value="No" disabled>T-Desk Online</option> -->
</select>
</th>
</tr>
<tr>
<th scope="row" style="font-size:10px" align="left">Venue</th>
<th width="179" bgcolor="#B8D8D8" scope="row">
<input type="text" Value="<?php echo $TrainingVenue;?>" required="required" name="Venue" id="Venue" disabled /></th>
<th width="327" scope="row" style="font-size:10px" align="center">City</th>
<th width="457" bgcolor="#B8D8D8" scope="row">
<input type="text" required="required" Value="<?php echo $TrainingCity;?>" name="City" id="City" disabled />
</th>
<tr>
<th scope="row" style="font-size:10px" align="left">Partner Organization (If any) </th>
<th colspan="3" bgcolor="#B8D8D8" scope="row" align="left">
<input type="text" name="PartnerOrg" Value="<?php echo $TrainingPartOrg;?>" id="PartnerOrg" disabled/>
</th>
</tr>
</table>
</div>
<table class="table table-bordered" width="1065" height="771" border="1" align="center">
</div>
<tr>
From Where i am getting ID:
$query = "select * from tbl_usr_training_master";
$rs = mysqli_query($con, $query);
$html ="";
$i=1;
while($row = mysqli_fetch_array($rs))
{
$html .='<tr>
<td>'.$row['trai_master_id'].'</td>
<td>'.$row['trai_name'].'</td>
<td>'.$row['trai_expertise'].'</td>
<td>'.$row['tari_program_title'].'</td>
<td>'.$row['trai_date'].'</td>
<td>'.$row['Venue'].'</td>
<td>'.$row['City'].'</td>
<td>'.$row['trai_type_cata'].'</td>
<td>'.$row['trai_type_subcata'].'</td>
<td>'.$row['t_days'].'</td>
<td>'.$row['trai_status'].'</td>' . '
<td>
<a href="#" class="view" title="View" data-toggle="tooltip"><i class="material-icons"></i></a>
<a href="post_form.php?rid='.$row['trai_master_id'].'" class="edit" title="Close Pre Budget Form" data-toggle="tooltip"><i class="material-icons"></i></a>
<a href="#" class="delete" title="Delete" data-toggle="tooltip"><i class="material-icons"></i></a>
</td>
</tr>';
$i=1;
}