I send input values with same names in array(ID inside) by post as it shown bellow
<form action="" method="POST" role="form" name="formetn" enctype="multipart/form-data">
<input type="text" name="videolinks[<?php echo $videoid; ?>]" value="<?php echo $videolink; ?>" class="form-control">
</form
Here I am getting array and parse it
if(isset($_POST["hidden_input_name"]) && $_POST["hidden_input_name"]!="")
{
$ppp = $_POST['videolinks'];
$arraylength = count($ppp); //here i got count of sent items
$ids = implode(",",array_keys($ppp)); //here I parse keys
$escaped_values = array_map('mysql_real_escape_string', array_values($ppp));
$values = implode(",", $escaped_values); //here I parse values
}
Now I need to check if i have same ID in my table--> do update of this row
If it is new ID --> do Insert this row
for($i = 0; $i < $arraylength; $i++)
{
while($row = mysqli_fetch_array($selectvidelink))
{
$videoid = $row["ID"];
if ($videoid == key($ppp))
{
//do update of this row
}
else
{
//do insert of this row
}
}
}
I know that I do wrong smth, but do not know what exactly I should change to check array.