2013-06-15 2 views
-2

나는 이것을 가지고있다.배열 값을 PHP의 단일 변수로 가져 오기

  <?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>"; 
      ?> 

결과를 단일 변수로 가져올 수 있습니까? 그러면 변수를 echo 할 때 같은 것을 인쇄 할 수 있어야합니다!

+0

모든 HTML 문자열을 단일 변수로 가져와야한다는 의미입니까? 그리고 그것을 반향시킬 때 테이블은 그대로 인쇄되어야합니다. – tornados

+1

나는 당신이 무엇을 원하는지 정말로 모른다. .. – Ali

답변

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; 
?> 
+0

Oh 그런 단순한 물건 나는 부서 질 수 없었다. .. 나에게 불행한! lol –

+0

np, 도와 줘서 기쁩니다. –

0

그런 변수에 대한 모든 에코를 추가, http://php.net/manual/en/language.operators.string.php

같은 :

$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; 
관련 문제