How to delete duplicate row in mysql table based on the value of a third column in php -
i new php. asking delete row according value of third column. table consist of id , datetime fields. here code tried stuck next:
$cxn = mysqli_connect($host,$user,$pass,$dbname) or die("couldn't connect server"); $qry = "select id, date(validdatetime) date, time(validdatetime) time tempstore order id"; $result = mysqli_query($cxn,$qry) or die("couldn't execute query"); while ($row=mysqli_fetch_assoc($result)) { extract($row); $hours = date("h",strtotime($time)); if ($id[$i] == $id[$i+1]) { echo "<p>$id $date $hours</p>\n"; } $i++; //print_r($hours); }
i extract date , time datetime fields in table extract again hours time distinguish if user have inputs in same hour in same date , delete leaving his/her first inputs in different hours. hope can understand trying achieve , me solve problem. thank in advance.
Comments
Post a Comment