if((isset($_POST['page_id'])) && (isset($_POST['page_title'])) && (isset($_POST['page_file_name']))) {
$_POST['page_id'];
$page_id = $_POST['page_id'];
$page_title = $_POST['page_title'];
$page_file_name = $_POST['page_file_name'].".txt";
//to check if id or page already exists in database or not
$sql_page_check = "SELECT * FROM page";
$sql_page_check_result = mysqli_query($conn,$sql_page_check);
if($sql_page_check_result == true){
if(mysqli_num_rows($sql_page_check_result)>0){
$pages_present = mysqli_num_rows($sql_page_check_result);
while($page = mysqli_fetch_assoc($sql_page_check_result)){
if(($page['page_id']==$page_id) || ($page['page_title']==$page_title) || ($page['page_file_name']==$page_file_name)){
echo "Page Id ($page_id) /$page_title/$page_file_name already exists in database, please check and try again";
break1;
}
elseif(($page_id=="") || ($page_title=="") || ($page_link=="")){
echo ("<b style='color:red;'>Please fill all fields.</b>");
break;
}
else{
if(!file_exists("../pages/".$page_file_name)){
fopen("../pages/".$page_file_name,"w");
$sql_add_menu = "INSERT INTO page VALUES('$page_id','$page_title','$page_file_name')";
$sql_add_menu_result = mysqli_query($conn,$sql_add_menu);
if($sql_add_menu_result == true){
echo"<b style='color:green;'>$page_title Page Added</b>";
}
}
}
}
}
}
}
include "footer.php";
問題是每個錯誤消息必須顯示在循環內並顯示多次,如果我使用break,die,退出footer.php底部不顯示出來,還有一部分不起作用!問題與在PHP中的循環斷開
'break1'無效。這是在原始頁面還是複製錯誤? – Barmar
@Barmar ya它只是break1 [只是測試,如果萬一它的工作],通過互聯網搜索解決方案,我發現我們也可以使用break1 break2也取決於有多少循環打破。 –
我想那裏需要有一個空格之前的數字,我猜不是。但是沒有理由使用這個數字,除非你需要從內部循環中突破外部循環。 – Barmar