這是一個讓我難倒的人。在沒有空值的情況下將POST數組存儲在mysql中?
我將$ _POST數組存儲在mysql數據庫中。我正在使用JavaScript動態創建我的表單上的輸入字段,但如果輸入字段爲空,仍然會被插入到數據庫中(顯然)。
無論如何要通過POST數組並過濾這些空值嗎?
編輯:
使用WordPress的,但同樣的想法:
<?php
foreach($_POST['eirepanel_inline_ads_options_name'] as $post_eirepanel_inline_ads_options_name):
if(empty($post_eirepanel_inline_ads_options_name)):
echo 'empty';
else:
update_option('eirepanel_inline_ads_options', $_POST);
$eirepanel_inline_ads_options = get_option('eirepanel_inline_ads_options');
endif;
endforeach;
?>
你如何處理提交按鈕值?你認爲什麼是空值?空串? 0? – hakre 2011-06-15 12:18:40
提交值有一個布爾值。一個空值將是一個空字符串 – 2011-06-15 12:22:35
嗯,提交按鈕上顯示的文字是什麼? – hakre 2011-06-15 12:24:33