阅读背景:

在同一个表中显示两个数组

来源:互联网 
$row = $query->fetchAll(PDO::FETCH_ASSOC);
$num_rows = count($row);

for ($i = 0; $i < $num_rows; $i++)
{
    $title = htmlspecialchars($row[$i]['title']);
    $author =htmlspecialchars($row[$i]['author']);
    $school =htmlspecialchars($row[$i]['school']);
    $solution = $row[$i]['solution'];
    $notes = $row[$i]['notes'];

    $ad = array($title, $price, $author, $school, $contact, $content, $date);
    $inlcude = array($solutions, $notes);

    $field = 0;
    echo "<table border='1'>";    
    // foreach($inlcude as $in) This failled miserably 
    foreach ($ad as $post)
    {
        if ($field < 3) //The first three values are placed in the first row

        {
            echo "<td>$post</td>"; 
        }
        if ($field >= 3) 
        {         
            echo "<tr><td>$post</td><td>$in</td></tr>";   
        }
        $field++;
    }
    echo '</table>';
}
$row = $query->fetchAll(PDO::FETCH_ASSOC);
$num



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: