如果之前有人问过的话,我很抱歉!这就是我想做的。
我需要更新“其他”列,其中$last8等于项目id的最后8个字符
例如
我的数据库里有8542658s5s4a2158
我需要做
$lasteight=“5s4a2158”;
mysqli_query($con,“UPDATE inv SET other=”log_itm“WHERE item_id=”$lasteight“);
再次抱歉,如果在我搜索数小时之前就被问到这个问题!!
万分感谢!

最佳答案

$lasteight = mysqli_real_escape_string($_POST['lasteight']);

mysqli_query($con, "
    UPDATE inv SET
        other = 'log_itm'
    WHERE
        RIGHT(item_id, 8) = '$lasteight'
");

// OR

mysqli_query($con, "
    UPDATE inv SET other = 'log_itm' WHERE item_id LIKE '%". $lasteight ."'
");

关于php - mysqli更新,如果项目ID,则项目ID等于最后八个,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25777003/

10-12 12:40
查看更多