Insertion error (PHP) [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I've been looking for a solution to this problem, but with no luck. Basically when inserting an item in a table it doesn't return a result (doesn't insert anything). I've checked the table fields and all match, I can't seem to find what error I'm doing.
Here's the portion of the code I currently have, where the problem occurs.
<br>
<h3><center><b>Components management</b></center></h3>
<br>
<form name = "registo" method = "POST" action = "">
<center><fieldset>
<legend>Insert component</legend>
<br>
<p><b> Nome: <input type = "text" name = "component_name" required></b> </p><br>
<p> <b>Type:</b> </p>
<div class = "mytable">
<table><tr>
<?php
$queryComp_Type = "select id, name from conc_type order by name";
$resultadoQueryComp_Type = mysqli_query($conn, $queryComp_Type);
foreach ($resultadoQueryComp_Type as $rowComp_Type)
{
?>
<th><?php echo $rowComp_Type['name']; ?></th>
<?php
}
?>
</tr><tr>
<?php
foreach ($resultadoQueryComp_Type as $rowComp_Type)
{
?>
<td><input class= "radio" type= "radio" name= "component_type" value= "<?php echo $rowComp_Type['id']; ?>" required> </td>
<?php
}
?>
</tr></table>
</div><br>
<p> <b>State:</b></p>
<table class="mytable">
<tr><th>Active</th><th>Inactive</th></tr>
<tr>
<td> <input class= "radio" type= "radio" name= "component_state" value= "active" required></td>
<td> <input class= "radio" type= "radio" name= "component_state" value= "inactive"></td>
</tr>
</table>
<br>
<!--Insert button-->
<input type= "hidden" name= "state" value= "inserir">
<input class= "button" type= "submit" value= "Inserir Componente">
<br><br>
</fieldset></center>
</form>
<?php
}
else if($_REQUEST['state'] == "inserir")
{
?>
<h3>Components management - inserçtion</h3>
<?php
$component_name = $_REQUEST['component_name'];
$component_type = $_REQUEST['component_type'];
$component_state = $_REQUEST['component_state'];
$insert = sprintf("INSERT INTO `concept` (`name`,`conc_type_id`,`state`) VALUES ('%s', '$component_type', '%s')", mysqli_real_escape_string($conn, $component_name),
mysqli_real_escape_string($conn, $component_state));
$resultado_insert = mysqli_query($conn, $insert);
if($resultado_insert)
{
mysqli_query($conn,'COMMIT');
?>
<p>Insert successfuly</p>
<p>Click in Continue to advance.</p>
<?php
}
else
{
mysqli_query($conn,'ROLLBACK');
?>
<p>Insertion error.</p>
<?php
}
back();
}
}
?>
If anyone could help I'd be really grateful!
EDIT: Changed $$component_name to $component_name. (Typo)
EDIT: Full page code.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css"href="/custom/css/ag.css">
</head>
<body>
<?php
require_once("custom/php/common.php");
if(!is_user_logged_in() && !current_user_can('manage_components'))
{
echo "You don't have permission to access this page";
}
else
{
if($_REQUEST['state'] == "")
{
$verify_component = "SELECT * FROM concept";
$result_component = mysqli_query($conn, $verify_component);
if(mysqli_num_rows($result_component) == 0)
{
echo "Não há componentes";
}
else
{
?>
<table class="mytable">
<thead><tr>
<th>Type</th>
<th>ID</th>
<th>Name</th>
<th>State</th>
<th>Ação</th>
</tr></thead>
<!--<tbody>-->
<?php
$choice_comp_type = "SELECT * FROM conc_type";
$resultado_comp_type = mysqli_query($conn, $choice_comp_type);
while($type = mysqli_fetch_array($resultado_comp_type))
{
$choice_components = "SELECT component.*
FROM concept,conc_type
WHERE conc_type.id = concept.conc_type_id
AND conc_type_id = '".$type['id']."'";
$result_components = mysqli_query($conn, $choice_components);
$num_rows = mysqli_num_rows($result_components);
if($num_rows > 0)
{
?>
<tr>
<td class= "Name" colspan = "1" rowspan = "<?php echo $num_rows; ?>"> <?php echo $type['name']; ?> </td>
<?php
while($row = mysqli_fetch_array($result_components))
{
?>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['name'];?></td>
<?php
if($row['state'] == "active")
{
?>
<td>active</td>
<td>[edit] [desactivate]</td>
<?php
}
else
{
?>
<td>inactive</td>
<td>[edit] [activate]</td>
<?php
}
?>
</tr>
<?php
}
}
}
?>
<!--</tbody>-->
</table>
<?php
}
?>
<br>
<h3><center><b>Management Compontent - introduction</b></center></h3>
<br>
<form name = "registo" method = "POST" action = "">
<center><fieldset>
<legend>Insert component</legend>
<br>
<p><b> Name: <input type = "text" name = "component_name" required></b> </p><br>
<p> <b>Type:</b> </p>
<div class = "mytable">
<table><tr>
<?php
$queryComp_Type = "select id, name from conc_type order by name";
$resultadoQueryComp_Type = mysqli_query($conn, $queryComp_Type);
foreach ($resultadoQueryComp_Type as $rowComp_Type)
{
?>
<th><?php echo $rowComp_Type['name']; ?></th>
<?php
}
?>
</tr><tr>
<?php
foreach ($resultadoQueryComp_Type as $rowComp_Type)
{
?>
<td><input class= "radio" type= "radio" name= "component_type" value= "<?php echo $rowComp_Type['id']; ?>" required> </td>
<?php
}
?>
</tr></table>
</div><br>
<p> <b>State:</b></p>
<table class="mytable">
<tr><th>active</th><th>Inactive</th></tr>
<tr>
<td> <input class= "radio" type= "radio" name= "component_state" value= "active" required></td>
<td> <input class= "radio" type= "radio" name= "component_state" value= "inactive"></td>
</tr>
</table>
<br>
<!--Botão Inserir-->
<input type= "hidden" name= "state" value= "inserir">
<input class= "button" type= "submit" value= "Inserir Componente">
<br><br>
</fieldset></center>
</form>
<?php
}
else if($_REQUEST['state'] == "inserir")
{
?>
<h3>Management component - insertion</h3>
<?php
$component_name = $_REQUEST['component_name'];
$component_type = $_REQUEST['component_type'];
$component_state = $_REQUEST['component_state'];
$insert = sprintf("INSERT INTO `concept` (`name`,`conc_type_id`,`state`) VALUES ('%s', '%s', '%s')", mysqli_real_escape_string($conn, $component_name), mysqli_real_escape_string($conn, $component_type),
mysqli_real_escape_string($conn, $component_state));
$resultado_insert = mysqli_query($conn, $insert);
if($resultado_insert)
{
mysqli_query($conn,'COMMIT');
?>
<p>Successfull insertion</p>
<p>Click in Continue to advance.</p>
<?php
}
else
{
mysqli_query($conn,'ROLLBACK');
?>
<p>Insertion error</p>
<?php
}
back();
}
}
?>
</body>
</html>

First when you create a table... get a result of query... i think should be like this :
<div class = "mytable">
<?php
$queryComp_Type = "select id, name from conc_type order by name";
$resultadoQueryComp_Type = mysqli_query($conn, $queryComp_Type);
$tableHeader = "";
$tableBody = "";
?>
<table>
<thead>
<?php
while ($row = mysqli_fetch_array($resultadoQueryComp_Type)) {
$tableHeader .= '<tr>
<th>'.$row['name'].';</th>
</tr>';
}
?>
<?=$tableHeader?>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_array($resultadoQueryComp_Type)) {
$tableBody .= '<tr>
<td>'.$row['id'].'</td>
</tr>';
}
?>
<?=$tableBody?>
</tbody>
</table>
</div>

Related

I am developing php page for update function

when page is loaded it display error that id, name and address is undefined. These variable are getting on condition of edit, but i dont understand how to place these values in text filed 'value' for edit as this is not working. The main code is like this.*** also the code of update is not updating values but it displays your record is updated
<?php
include 'server.php';
if (isset($_GET['edit'])) {
$id = $_GET['edit'];
$update = true;
$record = mysqli_query($con, "SELECT * FROM info WHERE id=$id");
if (count($record) == 1) {
$n = mysqli_fetch_array($record);
$name = $n['name'];
$address = $n['address'];
}
}
?>
<!-- Form -->
<!DOCTYPE html>
<html>
<head>
<title>CReate, Update</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form method="post" action="php_code.php" >
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="text" name="name" value="<?php echo $name; ?>">
<input type="text" name="address" value="<?php echo $address; ?>">
<div class="input-group">
<?php if ($update == true): ?>
<button class="btn" type="submit" name="update" >Update</button>
<?php else: ?>
<button class="btn" type="submit" name="submit" >save</button>
<?php endif ?>
</div>
</form>
<!-- Display -->
<?php
$i = 1;
$q = mysqli_query($con, "select*from info");
while ($f = mysqli_fetch_array($q)) {
?>
<table>
<th> sr N0</th>
<th> Name</th>
<th> address</th>
<th> Action</th>
<tr>
<td> <?php echo $i; ?> </td>
<td> <?php echo $f['name']; ?> </td>
<td> <?php echo $f['address']; ?> </td>
<td><a href="index.php?edit=<?php echo $f['id']; ?>" class="edit_btn" >Edit</a></td>
</tr>
<?php $i ++;
}
?>
</table>
</body>
</html>
<?php
include 'server.php';
if (isset($_POST['save']))
{
$name= $_POST['name'];
$add= $_POST['address'];
$q = "INSERT into info (name,address) VALUES ('$name', '$add')";
mysqli_query($con, $q);
echo "inserted";
}
if (isset($_POST['update']))
{
$uname= $_POST['name'];
$uaddress= $_POST['address'];
$q = "UPDATE info set name= '$uname', adress= '$uaddress' WHERE id = $id";
mysqli_query($con, $q);
echo "updated";
}
?>
Make
if (count($record) == 1 ) {
to
if (mysqli_num_rows($record) == 1 ) {

Need to Insert Multiple Data by selecting Checkboxes

I need to Insert data to the DB using the form given below
<form action="OtherEventPayment.php" id="frmSignIn" method="post">
<input type="hidden" name="online_id" value="<?php echo $lid; ?>" >
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Item</th>
<th>No. of Participants</th>
<th>Tick the Items</th>
</tr>
</thead>
<tbody>
<tbody>
<?php
$sn ="1";
$id = $oth_event_id;
$stmt1 = $DB_con->prepare('SELECT * FROM oth_events_details
LEFT JOIN oth_event_category ON (oth_events_details.oth_evcat_id=oth_event_category.oth_evcat_id)
WHERE oth_event_id =:uid ORDER BY oth_event_det_id DESC');
$stmt1->execute(array(':uid'=>$id));
$stmt1->execute();
if($stmt1->rowCount() > 0)
{
while($row1=$stmt1->fetch(PDO::FETCH_ASSOC))
{
extract($row1);
?>
<tr>
<td><?php echo $sn; ?></td>
<td>
<?php echo $row1['oth_category'];?> -
<?php
$group =$row1['oth_catgroup_type'];
if ($group=="S")
{
echo "Single";
}
elseif ($group=="D")
{
echo "Doubles";
}
else{
echo "Group";
}
?>
</td>
<td><?php echo $row1['participntno']; ?></td>
<td>
<b>
</b>
<input type="checkbox" name="chk[<?php echo $row1['oth_event_det_id'];?>]" value="<?php echo $row1['oth_event_det_id'];?>" id="chk[<?php echo $row1['oth_event_det_id'];?>]" />
Fees:- <?php echo $row1['oth_ev_fee'];?>
</td>
</tr>
<?php $sn++; ?>
<?php
}
}
else
{
?>
<div class="col-xs-12">
<div class="alert alert-warning">
<span class="glyphicon glyphicon-info-sign"></span> No Data Found ...
</div>
</div>
<?php
}
?>
</tbody>
</table>
<div class="col-md-6">
<input type="submit" name="selectItems" value="Submit & Proceed" class="btn btn-primary pull-right mb-xl" data-loading-text="Loading...">
</div>
</div>
<?php echo $sn1=$sn-1; ?>
</form>
in the OtherEventPayment.php i have written the code. But not working . How to Insert data correctly to DB
<?php
require_once 'dbconfig.php';
if(isset($_POST['selectItems']))
{
echo array[] = $_POST['chk[]'];
echo $oth_online_id= $_POST['online_id'];
if($oth_event_detid != ""){
for($i=0;$i<sizeof($oth_event_detid);$i++)
{
// oth_event_det_id,oth_online_id
$stmt = $DB_con->prepare('INSERT INTO othevents_itemsonline(oth_event_det_id,oth_online_id) VALUES( :oth_event_det_id, :oth_online_id)');
$stmt->bindParam(':oth_event_det_id',$oth_event_det_id);
$stmt->bindParam(':oth_online_id',$oth_online_id);
if($stmt->execute())
{
$lastonlineid= $DB_con->lastInsertId();
$successMSG = "Thank you For Registering with us . Please select the items to be participating...";
// header("refresh:0;OtherEventsOnlineRegistrationThankyou.php"); /
}
else
{
$errMSG = "error while registering....";
} } }
}
?>
Name should be same for input field. Use following code:
<input type="checkbox" name="chk[]" value="<?php echo $row1['oth_event_det_id'];?>" id="chk[<?php echo $row1['oth_event_det_id'];?>]" />
Fees:- <?php echo $row1['oth_ev_fee'];?>
You can see name. Hopefully it will be clear enough
Just change the value of you checkboxes and the value it represents but keep the name same with the others, yet it should have a name with []
<input type="checkbox" id="chk<?php echo $row1['oth_event_det_id'];?>" name="chk[]" value="<?php echo $row1['oth_event_det_id'];?>">
<label for="chk<?php echo $row1['oth_event_det_id'];?>"><?php echo $row1['oth_event_det_id'];?></label>
having a name chk[] like this will send and serve as an array in your get or post-function so loop it on controller or function that will add it in the DB
upon inserting it,
$data = $_GET['chk']; //this is in array form
foreach($data as $chk){
//insert code here
}

onchange dropdown show checkbox is checked in php

code:
<script>
$(document).ready(function(){
$(".menu").click(function(){
ids = $('.menu:checked').map(function() {
return this.id;
}).get().join(',');
console.log(ids);
$("#ids").val(ids);
});
});
</script>
<?php
if(isset($_POST['submit']))
{
$adminid = $_POST['admin'];
$menuids = explode(",", $_POST['ids']);
foreach ($menuids as $idd)
{
$sql = "update menu set admin_id = concat(admin_id,'$adminid',',') where id = '$idd'";
$result = mysqli_query($link,$sql);
}
if($result == true)
{
$msg .= "<p style='color:green'>successfull</p>";
}
else
{
$msg .= "<p style='color:red'>error!</p>";
}
}
?>
<form method="post">
<select name="admin" id="admin">
<option value="">---Select Admin---</option>
<?php
$sql = "select * from admin";
$result = mysqli_query($link,$sql);
while ($row = mysqli_fetch_array($result))
{
?>
<option value="<?php echo $row['id']; ?>"><?php echo $row['firstname']?></option>
<?php
}
?>
</select>
<table>
<tr>
<th>Share</th>
<th>Menu Name</th>
</tr>
<?php
$query = "select * from menu";
$results = mysqli_query($link,$query);
while ($fetch = mysqli_fetch_array($results))
{
?>
<tr>
<td>
<input type="checkbox" class="menu" id="<?php echo $fetch['id']; ?>" name="menuid" />
</td>
<td>
<?php echo $fetch['menu_name']; ?>
</td>
</tr>
<?php
}
?>
</table>
<input type="text" name="ids" id="ids" value=""/>
<input type="submit" name="submit" id="submit" />
</form>
In this code I am update a table having name menu in database. Now, I want to check only those checkbox where admin_id like ,1, or ,2, which is update by query. How can I fix this issue ?please please help.
Thank You
while ($fetch = mysqli_fetch_array($results))
{
?>
<tr>
<td>
<input type="checkbox" class="menu" value="<?php if($fetch['id']==1 or
$fetch['id']==2 ) { echo "checked";} else{} ?>" name="menuid" />
</td>
<td>
<?php echo $fetch['menu_name']; ?>
</td>
</tr>
<?php
}
?>

Printing Submit button for each row

I have problem with my buttons. I will try to explain.
1)I have users db from postgresql and new db in ms sql.
2)Created site with 2 columns in table ("SELECT * from users"-postgresql ): They are id/user
3)Then added new column "Operator" which contain submit buttons and functionality of submit buttons is updating "access" column from ms sql db.
PROBLEM:
It prints all buttons for all data that I have in ms sql(I have 7 rows data in ms sql, it prints 7 buttons for each row), I need to "echo" 1 button for each row which will be changable. If access==1 it should be named Active , else it should be named Diactive.
Here is my code and picture of what I got:
<?php
<table class="table table-condensed">
<thead>
<tr>
<th>ID</th>
<th>User</th>
<th>Operator</th>
<th>View</th>
</tr>
<?php
while ($row = pg_fetch_array($result)) {
?>
<tr>
<td>
<?php
$id = $row["id"];
echo $id;
?>
</td>
<td>
<?php
$username = $row["username"];
echo $username;
?>
</td>
<td>
<form method="POST" action="oper.php">
<?php
include ("db.php");
$result2 = pg_query($db_connection, "SELECT * from users ORDER by id asc");
while ($row1 = pg_fetch_array($result2))
{
$iddrain= $row1['id'];
//echo $iddrain;
//echo $iddrain;
$q7= "Select access from nezeret where id_m=$iddrain";
//var_dump($q7);
$resultid= sqlsrv_query($link, $q7, $params, $options);
while($row7= sqlsrv_fetch_array($resultid))
{
//$rs7=$row7['ID_M'];
$rs8=$row7['access'];
//echo $rs8;
//break;
if($rs8==1)
{
echo "<p><input type=\"submit\" name=\"uid\" value=Operator-ON onchange=\"this.form.submit()\"></p>
<p><input type=\"hidden\" name=\"uid\" value=$id onchange=\"this.form.submit()\"></p>";
}
else
{
echo "<p><input type=\"submit\" name=\"uid\" value=DIavtive onchange=\"this.form.submit()\"></p>
<p><input type=\"hidden\" name=\"uid\" value=$id onchange=\"this.form.submit()\"></p>";
}
}
}
?>
</form>
</td>
<?php
}
?>
</tr>
</table>
?>
You are doing typo mistake na dnot giving quote for value attributes near :
try like this :
if($rs8==1)
{
echo '<p><input type="submit" name="uid" value="Operator-ON" onchange="this.form.submit()"></p>
<p><input type="hidden" name="uid" value="'.$id.'" onchange=
"this.form.submit()"></p>';
}
else
{
echo '<p><input type="submit" name="uid" value="DIavtive" onchange="this.form.submit()"></p>
<p><input type="hidden" name="uid" value="'.$id.' onchange="this.form.submit()"></p>';
}
}
I have reditted your code to remove some errors that were making it fail to work;
<?php include ("db.php"); ?>
<table class="table table-condensed">
<thead>
<tr>
<th>ID</th>
<th>User</th>
<th>Operator</th>
<th>View</th>
</tr>
</thead>
<?php
//while ($row = pg_fetch_array($result)) {
<?php foreach( pg_fetch_array($result) as $row ) { ?>
?>
<tbody>
<tr>
<td<?php echo $row['id'] ?></td>
<td><?php echo $row['username'] ?></td>
<td>
<form method="POST" action="oper.php">
<?php
$result2 = pg_query($db_connection, 'SELECT * from users ORDER by id asc');
while ($row1 = pg_fetch_array($result2)) {
$iddrain = $row1['id'];
$q7 = "Select access from nezeret where id_m=$iddrain";
//var_dump($q7);
$resultid = sqlsrv_query($link, $q7, $params, $options);
while ($row7 = sqlsrv_fetch_array($resultid)) {
//$rs7=$row7['ID_M'];
$rs8 = $row7['access'];
if ($rs8 == 1) {
echo '<p><input type="submit" name="uid" value=Operator-ON onchange="this.form.submit()"></p>
<p><input type="hidden" name="uid" value=$id onchange="this.form.submit()"></p>';
} else {
echo '<p><input type="submit" name="uid" value=DIavtive onchange="this.form.submit()"></p>
<p><input type="hidden" name="uid" value=$id onchange="this.form.submit()"></p>';
}
}
}
?>
</form>
</td>
</tr>
</tbody>
</table>
I`ve changed code and now it is working, problem was additional useless fetch. Here is the code:
<table class="table table-condensed">
<thead>
<tr>
<th>ID</th>
<th>User</th>
<th>Operator</th>
</tr>
<?php
while ($row = pg_fetch_array($result)) {
?>
<tr>
<td>
<?php
$id = $row["id"];
echo $id;
?>
</td>
<td>
<?php
$username = $row["username"];
echo $username;
?>
</td>
<td>
<form method="POST" action="oper.php">
<?php
include ("db.php");
$iddrain= $row['id'];
$q7= "Select * from nezeret where id_m=$iddrain";
//var_dump($q7);
$resultid= sqlsrv_query($link, $q7, $params, $options);
while($row7= sqlsrv_fetch_array($resultid))
{
$rs8=$row7['access'];
//echo $rs8;
if($rs8==1)
{
echo "<p><input type=\"submit\" name=\"uid\" value=Operator onchange=\"this.form.submit()\"></p>
<p><input type=\"hidden\" name=\"uid\" value=$id onchange=\"this.form.submit()\"></p>";
}
else
{
echo "<p><input type=\"submit\" name=\"uid\" value=Nazeret onchange=\"this.form.submit()\"></p>
<p><input type=\"hidden\" name=\"uid\" value=$id onchange=\"this.form.submit()\"></p>";
}
}
?>
</form>
</td>
</tr>
<?php
}
?>
</tr>
</table>

Updating all rows at once in codeigniter, error in query

I am trying to update multiple rows simultaneously and I think my query is somewhat messed up while i am trying to update all my rows simultaneously. I am using CodeIgniter framework. I want to work on my query and the data being sent from the view but unable to get a logic to update all rows simultaneously. Please note that there should be only one update button as this is a requirement
My View code is:
<form action="" method="post">
<table border="1" style="background:none;width:100%;" RULES="ROWS" class="tab_data">
<thead>
<th width="30px">No</th>
<th >Action Item</th>
<th>Responsibility</th>
<th>Order</th>
<th>Mandatory?</th>
<th width = "100px" align="center">Actions</th>
</thead>
<tbody>
<?php
$serial_no = 1;
if(count($rows))
{
foreach($rows as $row)
{
?>
<tr>
<td><?php echo $serial_no; ?></td>
<td>
<?php
echo "<input type='hidden' class='col-md-4 form-control' name='checklist_id' value='"
.$row['checklist_id']."' />";
echo $row['action_item'];
?>
</td>
<td>
<?php echo $row['responsibility']; ?>
</td>
<td>
<input type="hidden" name="row_id[]" value="<?php echo $row['sequence']; ?>">
<input type="text" class="form-control" name="order[]" value="<?php echo $row['sequence']; ?>">
</td>
<td>
<input type="checkbox" class="" name="if_checklist<?php echo $row->checklist_id; ?>" value="1" echo 'checked'; >
</td>
<td align="center">
<?php
echo anchor('exits/delete_absconding_checklist/'.$row['checklist_id'],
"<i class='fa fa-trash-o' alt='Delete' title='Delete' rel='".$row['id']."' ></i>",
array('rel' => $row->id, 'class' => 'edit_row'));
?>
</td>
</tr>
<?php
$serial_no++;
}
}
?>
<tr>
<td></td><td></td><td></td><td></td>
<td>
<input type="hidden" name="action" value="update_order">
<button type="submit" name="submit" class="btn btn-info pull-right">Update</button>
</td>
</tr>
</tbody>
</table>
</form>
My Controller Code is:
function display_absconding_checklist()
{
if($this->input->post('action') == '_doDelete' || $this->input->post('action') == '_doChangeStatus')
{
$this->admin_init_elements->delete_rows('applicant_status');
}
if($this->input->post('action') == 'update_order')
{
$this->exit_common->update_absconding_checklist();
}
$data['rows'] = $this->exit_common->get_all_absconding_checklists();
$this->data['maincontent'] = $this->load->view('maincontents/backend_display_absconding_checklist', $data, true);
$this->load->view('layout', $this->data);
}
My Model code is:
function update_absconding_checklist($post_array)
{
$post_array = $this->input->post();
foreach($post_array['checklist_id'] as $key => $rowid)
{
if($rowid > 0)
{
if(isset($post_array['if_checklist'.$rowid]))
$in = '1';
else
$in = '0';
$sql1 = "UPDATE pr_absconding_checklists SET `action_item` = '"
.$post_array['action_item'][$key]
."', `sequence` = '".$post_array['sequence'][$key]
."', `if_checklist` = '".$in
."' WHERE `checklist_id` = ".$rowid;
}
else
{
$sql1 = "UPDATE pr_absconding_checklists SET `action_item` = '"
.$post_array['action_item'][$key]
."', `sequence` = '".$post_array['sequence'][$key]
."', `if_checklist` = '".$in."'";
}
$query1 = $this->db->query($sql1);
}
}
I am getting no errors but there are many errors in my code and i am messed up, i am attaching my table snapshot also, please recommend improvements
My Table name is pr_absconding_checklists

Categories