0

当我使用 PHP 运算符比较 2 个数组值时,我遇到了一些问题。并注意这样的错误:Notice: Undefined offset: 1 in C:\wamp\www\总是显示在我的浏览器上。我所做的一切都是为了修复它。但是当我执行它时它显示相同的结果。任何人都可以帮我解决它吗?

$perbandingan = mysql_query("SELECT * FROM ar_produk_detail WHERE id_produk = '$_GET[id]'");
    $rows = mysql_num_rows($perbandingan);
    while($w = mysql_fetch_array($perbandingan)){
        $w_id[] = $w['id_subkategori'];
        $p_id[] = $w['id_produk_det'];
        $d_id[] = $w['id_produk'];
    }

    $data = $_POST['checkbox'];
    $sum = count($data);

for($t = 0; $t < $rows; $t++){
    if($w_id[$t] == $data[$t]){ //Notices error always reference by this line
        mysql_query("DELETE FROM ar_produk_detail WHERE id_produk_det = '$p_id[t]'");
}
4

1 回答 1

2

You could just check to make sure the offsets exist in your conditional:

if(isset($w_id[$t]) && isset($data[$t]) && $w_id[$t] == $data[$t])
于 2013-05-24T02:55:56.880 回答