PHP分析POST重复值

T121581 2014-05-31 04:56:03
客户端HTML
<form action="new.php" method="post">
<input name="part" type="text" />
<input name="transysno" type="text" />
<input name="tranlineid" type="text" />
<input name="count" type="text" />

<input name="part" type="text" />
<input name="transysno" type="text" />
<input name="tranlineid" type="text" />
<input name="count" type="text" />
<input type="submit" name="post" value="提交" />
</form>


怎么在PHP服务端判断 两组part,transysno,tranlineid 是否相同 ,如果相同则获取相同count的和
...全文
237 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
傲雪星枫 2014-06-01
  • 打赏
  • 举报
回复
客户端html

<form action="news.php" method="post">
    <input name="part[]" type="text" />
    <input name="transysno[]" type="text" />
    <input name="tranlineid[]" type="text" />
        <input name="count[]" type="text" />
 
    <input name="part[]" type="text" />
    <input name="transysno[]" type="text" />
    <input name="tranlineid[]" type="text" />
        <input name="count[]" type="text" />
    <input type="submit" name="post" value="提交" />
</form>
news.php

if($_POST['part'][0]==$_POST['part'][1] && $_POST['transysno'][0]==$_POST['transysno'][1] && $_POST['tranlineid'][0]==$_POST['tranlineid'][1]){
    echo ($_POST['count'][0] + $_POST['count'][1]);
}else{
    echo 'part,transysno,tranlineid not match';
}
T121581 2014-06-01
  • 打赏
  • 举报
回复
结贴 参阅了 http://bbs.csdn.net/topics/360243533
xuzuning 2014-05-31
  • 打赏
  • 举报
回复
提交后 print_r($_POST); 就知道该怎么做了
T121581 2014-05-31
  • 打赏
  • 举报
回复
引用 1 楼 xuzuning 的回复:
php 要求传入的同名变量写作数组形式 所以你的表单中的两组同名控件,只会有一组被 php 接收到
写成数组 之后 怎么能 分析出 四个变量中三个变量的值是否相同 然后判断是否合并他们的count呢
xuzuning 2014-05-31
  • 打赏
  • 举报
回复
php 要求传入的同名变量写作数组形式 所以你的表单中的两组同名控件,只会有一组被 php 接收到

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧