donglaogu3788 2018-05-03 22:53
浏览 104
已采纳

选择特定单选按钮的值

We're trying to create a system where the selected radio(s) current file name will be pushed for future use.. this future use been the replacement of the last lines value.

Our frontend.php file (loops through each file and displays the amount of files worth of radio buttons next to the files data (table))

<?php
foreach($moduleFiles as $moduleFile) {
    $file = file($moduleFile);
    if ($file) {
        echo '<tr>';
        foreach($file as $lines)
        {
            echo  '<td>' . $lines . '</td>';
        }
        echo '<td>
        <form class="form-submit" method="post" action="includes/sendreview.php">
        <div class="form-check">
            <input class="form-check-input" type="radio" name="reviewbutton" value="'.$file.'">
        </div>
        </td>';
    }
    $files++;
}
?> 
</tbody>
</table>
<button type="submit" class="btn btn-secondary" >Send for Review</button>
</form>

and our backend.php file (line 8 = the last line of the file, in this case the "STATUS" of the module)

<?php 
    $myfile = "../files/modules/" . $_POST['reviewbutton']; 
    $selected = $_POST['reviewbutton']; 
    foreach($selected as $filetoopen)
    {
        foreach($myfile as $lines)
        {
            if ($line = 8)
            {
                fwrite($file, implode('', $lines)); 
                file_put_contents($file, "PROG", FILE_APPEND | LOCK_EX);
                fclose($myfile); 
            }           
        }   
    }       
?>

The idea was to get the button's "FILE" value from the "$_POST['reviewbutton']; " however that has the current output of "Array" when we're looking for the output of "filename.txt"

What am i doing wrong? This is my first time using radios with multiple possible selections.

EDIT -

I should have said...

Error on frontend.php =

Notice: Array to string conversion in C:\xampp\htdocs\modulemanager.php on line 52

line 52 = <input class="form-check-input" type="radio" name="reviewbutton" value="'.$file.'">

Error on backend.php =

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\includes\sendreview.php on line 5
</div>
  • 写回答

1条回答 默认 最新

  • douzhi7451 2018-05-03 23:43
    关注

    Using the wrong variable. Had to change from $file to $moduleFile in frontend.php

    Backend loop was also incorrect, recoded it.

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

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么