I Have a Table Which came from data base (controller.php)....
<?php
class masterClass
{
public $db_host = "127.0.0.1";
public $db_user = "root";
public $db_pass = "";
public $db_name = "bachelor_bd";
public $db;
public function __construct()
{
try
{
$this->db = new PDO("mysql:host={$this->db_host};dbname={$this->db_name}", $this->db_user, $this->db_pass);
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
$e->getMessage();
}
}
public function bazar_deposit_show_parson($bid)
{
$sql = $this->db->prepare("SELECT * FROM `bachelor_member` WHERE bachelor_id=:bid");
$sql->execute(array(':bid' => $bid));
while ($data = $sql->fetch(PDO::FETCH_ASSOC))
{
echo "<div class='float_left col-10'>
<div class='user-title col-3'><strong>$data[name]</strong></div>
<div class='user-title col-2'>
<input type='text' id='boxthree' name='deposit[]'>
</div>
<input type='hidden' name='mmid[]' value='$data[id]'>
<div class='edit col-1'><button type='submit' name='start_depo' class='btn btn-warning btn-lg btn-block'>Save</button>
</div>
</div>";
}
}} ?>
And Hear Is Post Page
<?php
// Header Area Goes Hear
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "../layout/header.php");
if (isset($_POST['submit']))
{
$row_data_id = array();
foreach($_POST['mmid'] as $row=>$mmid)
{
$mmid= $mmid;
$row_data_id[] = $mmid;
}
$row_data_deposit = array();
foreach($_POST['deposit'] as $row=>$deposit)
{
$deposit= $deposit;
$deposit= ($_POST['deposit'][$row]);
$row_data_deposit[] = $deposit;
}
$bachelor->update_bazar_deposit($row_data_id,$row_data_deposit);
if($bachelor)
{
echo "Update Successful"
}
}
//Bachelor Zone Left Sidebar
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "../layout/sidebar.php");?>
<div class="user-form post-block col-6">
<form action="bazar_deposit.php?b_zone=<?php $_GET['b_zone']; ?>&m_category=<?php $_GET['m_category']; ?>" method='POST'>
<?php if(isset($_GET['b_zone'])) { $bid=$_GET['b_zone']; $bachelor->bazar_deposit_show_parson($bid); } ?>
<button type='submit' name='submit' class='btn btn-warning btn-lg btn-block'>Save Recode</button>
</form>
</div>
<!-- Bottom navigation -->
<?php require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "../layout/footer.php"); ?>
And then when i submit my form it hits (controller.php)
public function update_bazar_deposit($mmid,$deposit)
{
$sql = $this->db->prepare("UPDATE `bazar_deposit` SET deposit=:deposit WHERE bachelor_member_id=:mmid");
$sql->bindparam(':mmid', $mmid[]);
$sql->bindparam(':deposit', $deposit[]);
$sql->execute();
return $sql;
}
I am new in PDO And OOP. OK, when i set the value $mmid[1] and $deposit[1] the database take the value. but this form repeat will be several time.its depend on user. user can repeat 1,2,3,4 or many times on this form filed. But i can't update my database all rows those Referred by mmid. i can update only one row. what can i do. Help pls.....!!!!