-3

私はこの問題に苦労しています.URLとステータスの名前を持つ2つの列があり、ループでこのhtmlテーブルにデータを投稿する必要があります.私が直面している問題は、列のタイトルが何度もループし続けることですが、私はそれが一度だけ欲しい...これは私のコードです

    <?php
    if (preg_match("/found/", $html))
        {

    echo '<table id="table-2">
<thead>
<tr>
<th>URL</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>'.$get_sites_link.'</td>
<td>Keyword Found</td>

</tr></tbody>
</table>';
    $vul_url[] = $get_sites_link1; 
    $links_duplicate_removed = array_unique($vul_url);
    file_put_contents($save_file, implode(PHP_EOL, $links_duplicate_removed));
    }
    else 
    {
    echo '<table id="table-2">
<thead>
<tr>
<th>URL</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>'.$get_sites_link1.'</td>
<td>Keyword Not Found</td>

</tr></tbody>
</table>'."</b>"."</br>";

    }
    }

    ?>

どんな助けでも大歓迎です:)

4

2 に答える 2

2

まあ、おそらくテーブルの開口部とヘッダーをループから外す必要があります。次のようなもの:

echo "This is the only time this line will be shown.\n";
for ($i = 0; $i < 5; $i++) {
    echo "This line was shown $i times!\n";
}

http://codepad.viper-7.com/Tis4wU

于 2012-05-15T20:39:41.960 に答える
0

物事を何度も表示するには、それを繰り返し、ループを作成する必要があります:

  • 為に

  • foreach

  • その間

  • 一方を行います

    for($i=0; $i <=100; $i++){ echo "It's the $i time that I show it"; end

于 2014-11-13T21:20:31.607 に答える