dongzice4895 2016-10-18 07:06
浏览 23

连续显示2个图像,并在php中为下一个图像开始一个新行

I am trying to show 2 images in a row .Curruntly when an image is displayed then the next image goes to a new row .what i want is that when 2 images are displayed in a row only then it should go to the next row .

for($i = 0; $i < $counter; $i++)
        {
            $path = "http://verfix.com/playground_app/assets/images/upload/".$data['inspection'][$i]->image;


        $toolcopy .= '<tr style"height:350px;"> 

                <td style="width:100px;">
                    P-'.$data['inspection'][$i]->id.'
                </td>

                <td style="width:420px;">
                    <img src="'.$path.'"  width="420" height="220">
                </td>

                </tr>';

        }

        $toolcopy .= '</table>[![enter image description here][1]][1]

Thank You for any help .

  • 写回答

1条回答 默认 最新

  • doulang5323 2016-10-18 07:18
    关注

    Try with this code, it should do the trick.

        $toolcopy = '<table>';
        for($i = 0; $i < $counter; $i++)
        {
            $path = "http://verfix.com/playground_app/assets/images/upload/".$data['inspection'][$i]->image;
    
                if($i === 0 || $i % 2 === 0) {
                    if($i > 0) $toolcopy .= '</tr>';
                    $toolcopy .= '<tr style"height:350px;">';
                }
                $toolcopy .= '
                <td style="width:100px;">
                    P-'.$data['inspection'][$i]->id.'
                </td>
    
                <td style="width:420px;">
                    <img src="'.$path.'"  width="420" height="220">
                </td>';
    
        }
        $toolcopy .= '</tr>';
        $toolcopy .= '</table>';[![enter image description here][1]][1]
    

    It places two images in two separate TD elements in the same TR, the next two images on the next row and so on.

    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大