mysql - How to Update one column in a database table using two array values in Php -


here have combined 2 arrays update column called age in employee table. unfortunately values of column not getting updated.

bellow $names[] , $ages[] 2 arrays.

foreach (array_combine($names, $ages) $e => $f)  { $sql = "update `employee` set `age`= '" . $e . "' `a`= '" . $f . "'"; $query= mysql_query($sql); }  

instead if give print command

 echo $sql  // printing correct command,  update `employee` set `age`= '41' `a`= '" . samuel . "' update `employee` set `age`= '46' `a`= '" . sonal . "' 

i know there problem arrays update sql query don't know how rectify it.

that query can written way...

$sql = " update employee set age= $e a= '$f'; ";

also, (and obviously), don't store someone's age. store dob. , note mysql_ extension deprecated.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -