项目 post 有多个 phone 号码
item post with multiple phone numbers
此请求来自非程序员。下面给出了一个 Osclass 项目 post php 表单代码示例。
<?php
$action = 'item_add_post';
$prepare['s_phone_1'] = del_get_session('sPhone1') <> '' ? del_get_session('sPhone1') : @$item_extra['s_phone_1'];
?>
<div class="input-box">
<input type="tel" id="sPhone" name="sPhone1[]" value="" />
</div>
<div class="input-box">
<input type="tel" id="sPhone" name="sPhone1[]" value="" />
</div>
<div class="input-box">
<input type="tel" id="sPhone" name="sPhone1[]" value="" />
</div>
<?php
$prepare = $_POST['sPhone1'];
?>
<input type="hidden" name="sPhone1" value="<?php echo htmlentities(serialize($prepare['s_phone_1']));?>">
functions.php 页面也有以下代码。
function del_update_fields($item) {
if(!isset($item['pk_i_id']) || $item['pk_i_id'] <= 0) {
return false;
}
if(Params::existParam('sSold')) {
$fields = array(
's_phone' => (Params::getParam('contactPhone') <> '' ? Params::getParam('contactPhone') : Params::getParam('sPhone')),
's_phone_1' => Params::getParam('sPhone1'),
'i_condition' => Params::getParam('sCondition'),
'i_negotiable' => Params::getParam('sNegotiable'),
'i_transaction' => Params::getParam('sTransaction'),
'i_sold' => (Params::getParam('sSold') == 'on' ? 1 : Params::getParam('sSold'))
);
} else {
$fields = array(
's_phone' => (Params::getParam('contactPhone') <> '' ? Params::getParam('contactPhone') : Params::getParam('sPhone')),
's_phone_1' => Params::getParam('sPhone1'),
'i_condition' => Params::getParam('sCondition'),
'i_negotiable' => Params::getParam('sNegotiable'),
'i_transaction' => Params::getParam('sTransaction')
);
}
Item::newInstance()->dao->update(DB_TABLE_PREFIX.'t_item_delta', $fields, array('fk_i_item_id' => $item['pk_i_id']));
}
Screenshot of the db table
要求是在“s_phone_1”中的上述 3 个 name="sPhone1[]" 输入中存储 phone 个数字,如下例所示。
0091222222222;0091333333333;0091666666666;
但是它存储了N个;在 mysql。需要您的帮助来更正上述代码以将这些数字作为数组传递。稍后,需要将它们恢复到另一页中的 3 行,如下所示。
Phone 1: 0091222222222
Phone 2: 0091333333333
Phone 3: 0091666666666
提前致谢..
您正在获取数组中的值,现在这些数组值是您想要的“s_phone_1”
使用此代码获取“s_phone_1”中的值
在这里您可以将 $phonenumbers 存储在您的数据库中
$phonenumbers = implode(";",$_POST['sPhone1']);
//echo $phonenumbers;
产出
09874563214;09874563214;09874563214
现在根据您的要求获取价值
从数据库中获取值并将其存储在 $phonenumbers
$getPhoneNumbers = explode(";",$phonenumbers);
echo "Phone 1:" .$getPhoneNumbers[0]."<br>";
echo "Phone 2:" .$getPhoneNumbers[1]."<br>";
echo "Phone 3:" .$getPhoneNumbers[2]."<br>";
产出
Phone 1:09874563214
Phone 2:09874563214
Phone 3:09874563214
此请求来自非程序员。下面给出了一个 Osclass 项目 post php 表单代码示例。
<?php
$action = 'item_add_post';
$prepare['s_phone_1'] = del_get_session('sPhone1') <> '' ? del_get_session('sPhone1') : @$item_extra['s_phone_1'];
?>
<div class="input-box">
<input type="tel" id="sPhone" name="sPhone1[]" value="" />
</div>
<div class="input-box">
<input type="tel" id="sPhone" name="sPhone1[]" value="" />
</div>
<div class="input-box">
<input type="tel" id="sPhone" name="sPhone1[]" value="" />
</div>
<?php
$prepare = $_POST['sPhone1'];
?>
<input type="hidden" name="sPhone1" value="<?php echo htmlentities(serialize($prepare['s_phone_1']));?>">
functions.php 页面也有以下代码。
function del_update_fields($item) {
if(!isset($item['pk_i_id']) || $item['pk_i_id'] <= 0) {
return false;
}
if(Params::existParam('sSold')) {
$fields = array(
's_phone' => (Params::getParam('contactPhone') <> '' ? Params::getParam('contactPhone') : Params::getParam('sPhone')),
's_phone_1' => Params::getParam('sPhone1'),
'i_condition' => Params::getParam('sCondition'),
'i_negotiable' => Params::getParam('sNegotiable'),
'i_transaction' => Params::getParam('sTransaction'),
'i_sold' => (Params::getParam('sSold') == 'on' ? 1 : Params::getParam('sSold'))
);
} else {
$fields = array(
's_phone' => (Params::getParam('contactPhone') <> '' ? Params::getParam('contactPhone') : Params::getParam('sPhone')),
's_phone_1' => Params::getParam('sPhone1'),
'i_condition' => Params::getParam('sCondition'),
'i_negotiable' => Params::getParam('sNegotiable'),
'i_transaction' => Params::getParam('sTransaction')
);
}
Item::newInstance()->dao->update(DB_TABLE_PREFIX.'t_item_delta', $fields, array('fk_i_item_id' => $item['pk_i_id']));
}
Screenshot of the db table
要求是在“s_phone_1”中的上述 3 个 name="sPhone1[]" 输入中存储 phone 个数字,如下例所示。 0091222222222;0091333333333;0091666666666;
但是它存储了N个;在 mysql。需要您的帮助来更正上述代码以将这些数字作为数组传递。稍后,需要将它们恢复到另一页中的 3 行,如下所示。
Phone 1: 0091222222222 Phone 2: 0091333333333 Phone 3: 0091666666666
提前致谢..
您正在获取数组中的值,现在这些数组值是您想要的“s_phone_1”
使用此代码获取“s_phone_1”中的值 在这里您可以将 $phonenumbers 存储在您的数据库中
$phonenumbers = implode(";",$_POST['sPhone1']);
//echo $phonenumbers;
产出
09874563214;09874563214;09874563214
现在根据您的要求获取价值
从数据库中获取值并将其存储在 $phonenumbers
$getPhoneNumbers = explode(";",$phonenumbers);
echo "Phone 1:" .$getPhoneNumbers[0]."<br>";
echo "Phone 2:" .$getPhoneNumbers[1]."<br>";
echo "Phone 3:" .$getPhoneNumbers[2]."<br>";
产出
Phone 1:09874563214
Phone 2:09874563214
Phone 3:09874563214