需要帮助mysqli准备查询然后php进程然后更新每一行

$query = "SELECT id, noms FROM table ORDER BY id ASC";
$query2 = "UPDATE table SET `noms`=? WHERE `id`=?";
if ($stmt = $link->prepare($query)) {
    $stmt2 = $link->prepare($query2);
    $stmt2->bind_param('si',$noms,$id);
    $stmt->execute();
    mysqli_stmt_bind_result($stmt, $id, $noms);
    while (mysqli_stmt_fetch($stmt)){
        $noms = explode("|", $noms);
        for($i=0;$i<count($noms);$i++){
            $noms[$i]=$i.':'.$noms[$i];
        }
        $noms=implode('|',$noms);
        $stmt2->execute();
    }
}

This is what i want to do but there is a problem with collision between queries. How can i get rid of this?

this is simplified. php treatment is more complex. Not just explode/implode. Can't find a solution on google.

why you using this mysqli_stmt_bind_result($stmt, $id, $noms); ?

why don't you use this $stmt->bind_result($id, $noms); ?

Check this code :

$query = "SELECT id, noms FROM table ORDER BY id ASC";
$query2 = "UPDATE table SET noms=? WHERE id=?";
if ($stmt = $link->prepare($query)) {
    $stmt2 = $link->prepare($query2);
    $stmt2->bind_param('si',$noms,$id);
    $stmt->execute();
    $stmt->bind_result($id, $noms);
    while ($stmt->fetch()){
        printf ("%s (%i)
", $noms, $id);
        //$stmt2->execute();
    }
}