0

I am creating a program in which I am fetching data from database and showing it in a table. I don't know how much record will be fetch from the database, but I have to print 3 records in a single line, and next 3 in the another line. I have created the following program in the its printing all the records in the same line. I want it to limit this to 3 and after 3 records change line and print the next 3 record in the other line.

<body>   
    <table border="2px">
        <tr>
        <?php
        for($i=0; $i<=5; $i++)
        {
            echo "<td> $i </td>";
            $i=$i++;
        }
        ?>
        </tr>
    </table>
</body>

how to Mingw compiler compatible with Qt 4.8.5

i have problem when i want to compile progrmmes under Qt 4.8.5 and Mingw compiler

i tried many version of Mingw ( v 4.5.0 till 4.8 ) but alway i get the same error

c:\Qt\4.8.5\lib\libqtmaind.a(qtmain_win.o):-1: In function `WinMain@16':
c:\iwmake\build_mingw_opensource\src\winmain\qtmain_win.cpp:93: erreur : undefined reference to `_Unwind_Resume'
c:\iwmake\build_mingw_opensource\src\winmain\qtmain_win.cpp:135: erreur : undefined reference to `_Unwind_Resume'
c:\Qt\4.8.5\lib\libqtmaind.a(qtmain_win.o):-1: In function `ZN7QVectorIPcE7reallocEii':
c:\iwmake\build_mingw_opensource\src\corelib\tools\qvector.h:512: erreur : undefined reference to `_Unwind_Resume'
c:\iwmake\build_mingw_opensource\src\corelib\tools\qvector.h:513: erreur : undefined reference to `_Unwind_Resume'
qtmain_win.cpp:-1: erreur : undefined reference to `__gxx_personality_v0'
:-1: erreur : collect2: ld returned 1 exit status
4

4 回答 4

0

只是另一个示例,尝试这样的事情来准确地将表分解为3具有任何记录计数的列。在这种情况下$i是:<= 5

echo "<table border='2px'>";
for ($i = 0; $i <= 5; $i++) {
    if($i%3 == 0) echo "<tr>";
    echo "<td> $i </td>";
    if($i%3 == 2) echo "</tr>";
}
if($i%3 != 0) echo "</tr>";
echo "</table>";

你也不需要++$i 在里面!!消除$i=$i++;

于 2013-09-12T09:53:31.023 回答
0

尝试:

<?php
echo "<tr>";
for($i=0; $i<=5; $i++) {
  echo "<td>".$i."<td>";
  if( $i % 3 == 0 ) 
    echo "</tr><tr>";
  }
echo "</tr>";
?>
于 2013-09-12T09:48:26.530 回答
0

我建议您使用以下内容:

for($i=0; $i<=7; $i++){
    echo ($i%3 == 0) ? '<tr>' : ''; //Start a row
    echo "<td> $i </td>";
    echo ($i%3 == 2) ? '</tr>' : ''; //End a row after the third item
}
echo ($i%3 == 1) ? '<td></td><td></td></tr>' : ''; //End row adding two cells if only one is present after loop
echo ($i%3 == 2) ? '<td></td></tr>' : ''; //End row adding one cell if only one is present after loop

$i=$i++;在您的代码中不需要,因为它是在for初始化循环时定义的

完整代码

<table border="2px">
    <?php
    for($i=0; $i<=7; $i++){
        echo ($i%3 == 0) ? '<tr>' : '';
        echo "<td> $i </td>";
        echo ($i%3 == 2) ? '</tr>' : '';
    }
    echo ($i%3 == 1) ? '<td></td><td></td></tr>' : '';
    echo ($i%3 == 2) ? '<td></td></tr>' : '';
    ?>
</table>
于 2013-09-12T10:04:56.867 回答
-1
<table border="2px">

<?php
echo "<tr>";

for($i=0; $i<=5; $i++)
    {
    echo"
    <td> $i </td>";
    if($i % 3 == 0)
    echo "</tr>";
    $i=$i++;
    }

?>
</table>
于 2013-09-12T09:45:28.637 回答