0
我是PHP新手,並且無法理解數據是如何從表單傳遞到數據庫的。將此數據保存到數據庫的正確語法是什麼?
我的表格:
<select name="parentgallery" id="parentgallery">
<option value="0" ><?php _e('Choose gallery', 'nggallery') ?></option>
<?php
foreach($this->gallerylist as $gallery) {
//special case : we check if a user has this cap, then we override the second cap check
if (!current_user_can('NextGEN Upload in all galleries'))
if (!nggAdmin::can_manage_this_gallery($gallery->author))
continue;
$name = (empty($gallery->title)) ? $gallery->name : $gallery->title;
echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . $name . '</option>' . "\n";
} ?>
</select>
這select
我做是一起傳遞給該功能在同一頁上工作GalleryTitle
變種。所以我猜這是將數據傳遞到數據庫的好去處:
if ($_POST['addgallery']){
check_admin_referer('ngg_addgallery');
if (!nggGallery::current_user_can('NextGEN Add new gallery'))
wp_die(__('Cheatin’ uh?'));
$newgallery = esc_attr($_POST['galleryname']);
if (!empty($newgallery))
nggAdmin::create_gallery($newgallery, $defaultpath);
}
用PHP(這不同於我已經習慣了Rails的),是我看不到生命線麻煩這些數據傳遞給數據庫。我只能猜測正在通過什麼以及如何接收。
問題:
我如何可以張貼到數據庫我parentgallery
值旁邊的galleryname
變種?