2016-10-10 71 views
0

我繼承了一個使用會話和MySQL的PHP​​表單,該表單使用了一個無線電元素,該元素應該檢查當前無線電值是哪個值,並將其標記爲「已選中」以填充根據數據庫中的記錄校正無線電元素。所有其他表單元素都可以正確填充,只是這個單選元素沒有根據數據庫值0或1進行檢查。PHP isset不會填充表單中的無線電元素

這裏是代碼,我似乎缺少一些東西?

<label class="radioSublabel_Narrow" for="User_Update_group_4_Accepted__1"> Yes&nbsp; 
<input type="radio" name="User_Update_group_4_Accepted" id="User_Update_group_4_Accepted__1" value="1" class="formRadioField_Standard" <?php if (!(strcmp((isset($_GET["invalid"])?ValidatedField("userupdate","User_Update_group_4_Accepted"):""),"1"))) {echo "checked=\"checked\"";} ?> tabindex="4" title="Please enter a value."> 
</label> 
<label class="radioSublabel_Narrow" for="User_Update_group_4_Accepted__2"> No&nbsp; 
<input type="radio" name="User_Update_group_4_Accepted" id="User_Update_group_4_Accepted__2" value="0" class="formRadioField_Standard" <?php if (!(strcmp((isset($_GET["invalid"])?ValidatedField("userupdate","User_Update_group_4_Accepted"):""),"0"))) {echo "checked=\"checked\"";} ?> tabindex="5"> 
</label> 
+0

從我看到的我認爲':'列是在錯誤的地方坑是你的代碼顯示任何錯誤? –

+1

爲什麼使用'strcmp()'而不是僅僅比較'=='? – Barmar

+0

是否設置了$ _GET ['invalid']? – Barmar

回答

0

輸入元素缺少實際的數據庫列引用:

$ row_SecurityAssistMSFields [「接受」]

這裏是少了什麼的代碼的其餘部分的情況下:

<?php if (!(strcmp((isset($_GET["invalid"])?ValidatedField("userupdate","User_Update_group_4_Accepted"):"".$row_SecurityAssistMSFields["Accepted"] .""),"this"))) {echo "checked=\"checked\"";} ?> tabindex="4" title="Please enter a value.">