並べ替え機能を追加すると、コードに未定義のインデックス エラーが発生するのはなぜですか? これらは私が得ているエラーです
注意: 未定義のインデックス: 58 行目の C:\xampp\htdocs\how are things\admin panel\view.php のソート
注意: 未定義のインデックス: 61 行目の C:\xampp\htdocs\how are things\admin panel\view.php の並べ替え
注意: 未定義のインデックス: 64 行目の C:\xampp\htdocs\how are things\admin panel\view.php の並べ替え
注意: 未定義のインデックス: 67 行目の C:\xampp\htdocs\how are things\admin panel\view.php の並べ替え
注意: 未定義のインデックス: 70 行目の C:\xampp\htdocs\how are things\admin panel\view.php の並べ替え
Notice: 未定義のインデックス: sort in C:\xampp\htdocs\how are things\admin panel\view.php 行 73
注意: 未定義のインデックス: sort in C:\xampp\htdocs\how are things\admin panel\view.php 行 76
これは、58 61 64 67 70 73 76 行のコードです。
$result = "SELECT * FROM customers";
if($_GET['sort'] == 'first_name'){
$result .= " ORDER BY first_name";
}
else if($_GET['sort'] == 'last_name'){
$result .= " ORDER BY last_name";
}
else if($_GET['sort'] == 'address'){
$result .= " ORDER BY address";
}
else if($_GET['sort'] == 'phone_number'){
$result .= " ORDER BY phone_number";
}
else if($_GET['sort'] == 'email'){
$result .= " ORDER BY email";
}
else if($_GET['sort'] == 'city'){
$result .= " ORDER BY city";
}
else if($_GET['sort'] == 'country'){
$result .= " ORDER BY country";
}
$result = mysql_query($result) or die(mysql_error());