-2

私はこれを持っています。

           <?php
                $SQLbrands="SELECT * FROM brands";
                $runBrands=mysqli_query($db, $SQLbrands) or die ("SQL Error");
                $noRow=mysqli_num_rows($runBrands);

                echo "<table border='0' cellspacing='0' cellpadding='1' id='brndTable1' class='brndTable1'>";
                echo "<thead><tr><th class='brT11'>Brand Name</th><th class='brT21'>Variant</th><th class='brT31'>SKU</th>
                      <th class='brT41'></th></tr></thead>";
                echo "<tbody>";
                        while ($reK = mysqli_fetch_array($runBrands))
                        {
                        $wec = $reK['id']; $wec2 = $reK['bvariant']; $wec3 = $reK['bsku'];
                        echo "<tbody class='colormine'><tr>";
                        echo "<td class='brT1'>".$reK["bname"]."</td>";
                        echo "<td class='brT2'>".$reK["bvariant"]."</td>";
                        echo "<td class='brT3'>".$reK["bsku"]."</td>";
                        echo "<td class='brT4'><input type='checkbox' name='delz[]' value='$wec' ></td>";
                        echo "</tr>";
                        }   
                echo "</tbody>";
                echo "</table>";
            ?>

結果を単一の変数に入れることはできますか? したがって、変数をエコーすると、同じものが印刷できるはずです!

4

3 に答える 3

2

正しく理解していれば、文字列連結のようなもの:

<?php
$SQLbrands="SELECT * FROM brands";
$runBrands=mysqli_query($db, $SQLbrands) or die ("SQL Error");
$noRow=mysqli_num_rows($runBrands);


$brndTable = "<table border='0' cellspacing='0' cellpadding='1' id='brndTable1' class='brndTable1'>";
$brndTable .= "<thead><tr><th class='brT11'>Brand Name</th><th class='brT21'>Variant</th><th class='brT31'>SKU</th>
                      <th class='brT41'></th></tr></thead>";
$brndTable .= "<tbody>";
while ($reK = mysqli_fetch_array($runBrands))
{
    $wec = $reK['id']; $wec2 = $reK['bvariant']; $wec3 = $reK['bsku'];
    $brndTable .= "<tbody class='colormine'><tr>";
    $brndTable .= "<td class='brT1'>".$reK["bname"]."</td>";
    $brndTable .= "<td class='brT2'>".$reK["bvariant"]."</td>";
    $brndTable .= "<td class='brT3'>".$reK["bsku"]."</td>";
    $brndTable .= "<td class='brT4'><input type='checkbox' name='delz[]' value='$wec' ></td>";
    $brndTable .= "</tr>";
}
$brndTable .= "</tbody>";
$brndTable .= "</table>";


echo $brndTable;
?>
于 2013-06-15T07:42:34.030 に答える
0

Then add all your echo to variable, http://php.net/manual/en/language.operators.string.php

like:

$html = null;
$html .= "<table border='0' cellspacing='0' cellpadding='1' id='brndTable1' class='brndTable1'>";
$html .= "<thead><tr><th class='brT11'>Brand Name</th><th class='brT21'>Variant</th><th class='brT31'>SKU</th>
                  <th class='brT41'></th></tr></thead>";
$html .= "<tbody>";
.... etc...

echo $html;
于 2013-06-15T07:43:17.557 に答える
-1

If you want to get all the results from a query into 1 variable use this function

$all = mysqli_fetch_all($runBrands);

http://pl1.php.net/manual/en/mysqli-result.fetch-all.php

于 2013-06-15T07:44:42.217 に答える