dqp4933 2013-07-16 16:23
浏览 18
已采纳

php排序器脚本只输出相同的数据,即使我要求它做不同

okay so i have made the following script to sort some data i have in this format

0|1|2

heres my script (this now works)

    <html>
<body>
    <form method="post">
<div align="center"><textarea name="mp" cols="60" rows="10">0|1|2</textarea><br />

Delim: <input type="text" name="delim" value="|" size="1" />&nbsp;data1: <input type="text" name="mail" value="0" size="1" />&nbsp;data2: <input type="text" name="pwd" value="1" size="1" />&nbsp;
<input type="submit" value=" send " name="btn-submit" />
</div>
</form>
</body>
</html>
<?php

    if (isset($_POST['mp'], $_POST['delim'], $_POST['btn-submit'], $_POST['mail'], $_POST['pwd'])) {
        $mps = preg_split('/
||
/', $_POST['mp']);

        // Create an array to store results
        $result_data = array();

        // Iterate over requests
        foreach ($mps as $mp) {
            $mp = explode($_POST['delim'], $mp);

            // Store the account details in variables
            $email = $mp[$_POST["mail"]];
                  $password = $mp[$_POST["pwd"]];
            // Prepare a reusable string
            $result_string = "" . $email .  " : " . $password . "";
                            // Add result to the array
            $result_data[] = $result_string;






}
// Store of results complete. We now display them.
        if (count($result_data)) {
            echo "<ul
    list-style-type: none;
>";
            foreach ($result_data as $result_data_entry) {
                echo "<li list-style: none;>" . $result_data_entry . "</li>";
            }
            echo "</ul>";
        }
}




?>

i would now like to save the results into a text file also any help would be brilliant .

i am writing this extra line as my post has way way too much code .

  • 写回答

1条回答 默认 最新

  • dongshao9106 2013-07-16 16:33
    关注

    You aren't using the data1 and data2 fields anywhere in your PHP.

    I think instead of this:

    list($email, $password) = $mp;
    

    you need

    $email = $mp[$_POST["mail"]];
    $password = $mp[$_POST["pwd"]];
    

    It's also worth noting that the values supplied in those two fields will be zero based.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答