0

結果を HTML テーブルに出力しようとしています。解決するのを手伝ってください。

<?php global $wpdb;

$result1=$wpdb->get_results("select name from table1");

$result2=$wpdb->get_results("select name from table2");

$result3=$wpdb->get_results("select name from table3");


$result_one = array();
$result_two = array();
$result_three = array();

//putting values in array

foreach ($result1 as $result) {
    $result_one[] = $result
}

foreach ($result2 as $result) {
    $result_two[] = $result

    foreach ($result3 as $result) {
        $result_three[] = $result


        $results = array(
            $result_one,
            $result_two,
            $result_three,
        );
        $array_length = count($result_one);
   ?>

$results次に、HTML テーブルに印刷したいと思います。

------------------------------
   Name1  |  Name2   |  Name3
------------------------------
   Row1      Row1       Row1       
   Row2      Row2       Row2
   Row3      Row3       Row3
   Row4      Row4       Row4
   Row5      Row5       Row5

ご支援ありがとうございます。

4

2 に答える 2

1
<?php
$result1=array('ROW1','ROW1','ROW1');
$result2=array('ROW2','ROW2','ROW2');
$result3=array('ROW3','ROW3','ROW3');
$result_one = array(); 
$result_two = array(); 
$result_three = array(); 
//putting values in array 
foreach ($result1 as $result) { 
$result_one[] = $result; 
} 
foreach ($result2 as $result) 
{ 
$result_two[] = $result;
}   
foreach ($result3 as $result) { 
$result_three[] = $result;
} 
$results = array( $result_one, $result_two, $result_three);
?>
<table border=1>
<tr><td>Name1</td><td>Name2</td><td>Name3</td></tr>
<?php foreach($results as $row){ ?>
<tr>
<?php foreach($row as $val){?>
<td><?php echo $val;?> </td>
<?php } ?>
</tr>
<?php }?>
</table>
于 2013-08-13T05:23:19.050 に答える