Hi
I am trying to create a update function. But it not updating in the database. Please help me to fix.
Test-2.php
$whereString = '';
$bind = NULL;
if(isset($_POST['Submit']))
{
if($_POST)
{
$SCYQ64UKID = $_GET['SCYQ64UKID'];
$SCYQ64AVGP = $_POST['SCYQ64AVGP']*100;
$searchFields = array('SCYQ64EMAL'=>$_POST['SCYQ64EMAL'],'SCYQ64EV01'=>$_POST['SCYQ64EV01'],'SCYQ64EV02'=>$_POST['SCYQ64EV02'],'SCYQ64EV03'=>$_POST['SCYQ64EV03'],'SCYQ64EV04'=>$_POST['SCYQ64EV04'],'SCYQ64EV05'=>$_POST['SCYQ64EV05'],'SCYQ64EV06'=>$_POST['SCYQ64EV06'],'SCUSER'=>$_POST['SCUSER'],'SCYQ64AVGP'=>$SCYQ64AVGP,'SCYQ64TZ'=>$_POST['SCYQ64TZ'],'SCJOBN'=>gethostname(),'SCPID'=>'SSWEB','SCUPMJ'=>$_POST['SCUPMJ'],'SCUPMT'=>$_POST['SCUPMT']);
if($post = array_filter($_POST))
{
if($fields = array_intersect_key($searchFields, $post))
{
$where = array();
$bind = array();
foreach($fields as $key=>$field)
{
$where[] = "$key LIKE '%$field%'";
$bind[":$key"] = $_POST[$key];
$gwhere[] = "$key=$field";
$gbind[":$key"] = $_POST[$key];
}
//$whereString = ' WHERE ' . implode(' AND ', $where);
$gwhereString = implode(',', $gwhere);
}
$Users = new Users($db);
$query = $Users->smipleUpdate('FQ64000',$gwhereString,'SCYQ64UKID='.$SCYQ64UKID);
}
}
}
users.php
/*Update Query with array and id*/
public function smipleUpdate($tablen,$gwhereString,$whereCondition)
{
$query = $this->conn->prepare("Update $this->db_name.$tablen SET $gwhereString where $whereCondition");
try {
$query->execute();
return $query;
}catch(PDOException $e) {
die($e->getMessage());
}
}