Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php将数字打印/回显到复选框中_Php - Fatal编程技术网

如何使用php将数字打印/回显到复选框中

如何使用php将数字打印/回显到复选框中,php,Php,我的数据库中有一个名为num_ticket的表,我在其中保存了票证的总数,例如20 现在,我正在尝试将票号以数字模式打印到不同的复选框中,如1、2、3、4……到20。例如,复选框1,复选框2,复选框3,复选框4复选框20 我已经尝试过使用此 您需要使用循环来输出这些复选框/数字。将您的$post.=代码位放入for循环中(由于您输出的是从1开始的数字,请确保将循环的初始起始数字偏移为1,而不是典型的0) 对于($i=1;$i库存为一百万),这修复了我的问题+1 <?php

我的数据库中有一个名为
num_ticket
的表,我在其中保存了票证的总数,例如20

现在,我正在尝试将票号以数字模式打印到不同的复选框中,如
1、2、3、4……
到20。例如,
复选框1
复选框2
复选框3
复选框4
<代码>复选框20

我已经尝试过使用此


您需要使用循环来输出这些复选框/数字。将您的
$post.=
代码位放入
for
循环中(由于您输出的是从1开始的数字,请确保将循环的初始起始数字偏移为1,而不是典型的0)


对于($i=1;$i库存为一百万),这修复了我的问题+1
<?php
        if(isset($_GET['url']))
          $url = ($_GET['url']);
               $check = "SELECT * FROM raffels  WHERE  rid ='$url' ";
                             if ($result = mysqli_query($conn,$check))
                                 $totalres = mysqli_num_rows($result);       
                            if ($totalres ==0) {
                                 echo" <center><h1>Page Not Found</h1> May be the link was broken or the post has been deleted</p></center>";
                         //header("location: 404"); 
                           exit();
                            }

                              while($row = $result->fetch_assoc()) {

                                 $title = $row['title'];
                                 $price = number_format($row['amount']);
                                 $image = $row['image'];
                                 $num = $row['num_ticket'];


     $post.='<li class="seat col-xs-1 col-sm-1">
            <input type="checkbox" class="alterbutton" name="sport" 
                onchange="myFunction()" value="12" id="12" />
             <label for="12">'. implode("\n", range(1,  $num)) .'</label>    
             </li> ';

              }                       


     ?>
for ($i=1; $i<=$num; $i++)
{
    $post.='<li class="seat col-xs-1 col-sm-1">
        <input type="checkbox" class="alterbutton" name="sport" 
            onchange="myFunction()" value="' . $i . '" id="sport_checkbox_' . $i . '" />
        <label for="sport_checkbox_' . $i . '">' . $i . '</label>    
        </li> ';
}