当图像大于6时,我需要换行,怎么做呢?

时间:2021-08-17 07:54:51

When image are more than 6 I need a line break.

当图像超过6时,我需要换行。

       while($row  = mysql_fetch_array($q))
      {
         echo "<img src=\"$row[image_link]\" />";
      }

7 个解决方案

#1


1  

you can use mysql_num_rows()

您可以使用mysql_num_rows()

$cnt = mysql_num_rows($q);
if($cnt>6)
{
   echo "<br />";
}

#2


4  

Well you already had your answer so I'm just here to say that alternatively you can use in your images style="float: left".

你已经有了答案,所以我只是想说,你可以用你的图像样式="float: left"。

This will make them automatically break line when it is needed depending on the screen size instead of always doing it every 6 images.

这将使它们在需要的时候根据屏幕大小自动断线,而不是每6张图片都断线。

#3


1  

Try

试一试

    $i = 0;
    while($row  = mysql_fetch_array($q))
    {
        if ($i%6 == 0 && $i != 0)
        {
                echo "<br/>";
        }
        echo "<img src=\"$row[image_link]\" />";
        $i++;
    }

#4


0  

$count=1;
while($row  = mysql_fetch_array($q))
      {
         if($count%6==0) 
         echo "<br/>";
         echo "<img src=\"$row[image_link]\" />";
         $count++;

      }

#5


0  

    $count =0;
         while($row  = mysql_fetch_array($q))
              {
                 echo "<img src=\"$row[image_link]\" />";
                  $count++;
                   if($count>=6)
                     {
                     echo "</br>";
                     $count=0;
                     }                

              }

#6


0  

not good but try this if you want:

不是很好,但如果你想:

 $i = "1";
 while($row  = mysql_fetch_array($q))
  {
     echo "<img src=\"$row[image_link]\" />";
     if($i == 6){ echo "<br>";}
     $i++;
  }

#7


0  

Can you try this,

你可以试试这个,

    $i=1;
    while($row  = mysql_fetch_array($q))
      {

         echo "<img src=\"$row[image_link]\" />";

          if(($i%6)==0){ 
                echo "<hr/>";
          }
         $i++;

      }

#1


1  

you can use mysql_num_rows()

您可以使用mysql_num_rows()

$cnt = mysql_num_rows($q);
if($cnt>6)
{
   echo "<br />";
}

#2


4  

Well you already had your answer so I'm just here to say that alternatively you can use in your images style="float: left".

你已经有了答案,所以我只是想说,你可以用你的图像样式="float: left"。

This will make them automatically break line when it is needed depending on the screen size instead of always doing it every 6 images.

这将使它们在需要的时候根据屏幕大小自动断线,而不是每6张图片都断线。

#3


1  

Try

试一试

    $i = 0;
    while($row  = mysql_fetch_array($q))
    {
        if ($i%6 == 0 && $i != 0)
        {
                echo "<br/>";
        }
        echo "<img src=\"$row[image_link]\" />";
        $i++;
    }

#4


0  

$count=1;
while($row  = mysql_fetch_array($q))
      {
         if($count%6==0) 
         echo "<br/>";
         echo "<img src=\"$row[image_link]\" />";
         $count++;

      }

#5


0  

    $count =0;
         while($row  = mysql_fetch_array($q))
              {
                 echo "<img src=\"$row[image_link]\" />";
                  $count++;
                   if($count>=6)
                     {
                     echo "</br>";
                     $count=0;
                     }                

              }

#6


0  

not good but try this if you want:

不是很好,但如果你想:

 $i = "1";
 while($row  = mysql_fetch_array($q))
  {
     echo "<img src=\"$row[image_link]\" />";
     if($i == 6){ echo "<br>";}
     $i++;
  }

#7


0  

Can you try this,

你可以试试这个,

    $i=1;
    while($row  = mysql_fetch_array($q))
      {

         echo "<img src=\"$row[image_link]\" />";

          if(($i%6)==0){ 
                echo "<hr/>";
          }
         $i++;

      }