首先,我真的很高兴我偶然发现了这个网站,您的问题和回答帮助我完成了早期的作业 :) 现在我需要帮助 :( 我试图用我的代码做的是创建一个它应该有的表3 列“产品”“描述”“价格”。在以下每个标题下,我的数组“ $productImage
”位于“产品”列下,依此类推。我的问题是我似乎无法弄清楚如何在使用该foreach()
功能时制作表格。
任何帮助将不胜感激!
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
$productImage = array('http://www.rudebaguette.com/assets/PlayStation4 FeaturedImage.jpg', 'http://cdn0.mos.techradar.futurecdn.net//art/games_consoles/Xbox%20One/Press%20shots/Xbox%20One%20family-580-90.jpg', 'http://www.blogcdn.com/de.engadget.com/media/2009/08/razer-naga-mmo-mouse-all-set-to-create-a-new-world-record11.jpg', 'http://cdn1.mos.techradar.futurecdn.net//art/gadgets/Google%20Glass/google_glass_grey-580-90.jpg', 'http://img1.targetimg1.com/wcsstore/TargetSAS//img/p/10/02/10029875.jpg');
$description = array('PS4 ', 'Xbox One', 'Razer Naga', 'Google Glass', 'Magic Bullet');
$price = array('400', '350', '70', '300', '50');
echo '<table>';
foreach ($productImage as $pic)
{
echo '<tr>';
echo '<td>';
echo "<img src='".$pic."' width='200' height='180'>";
echo '</td>';
echo '</tr>';
}
foreach ($description as $des)
{
echo '<tr>';
echo '<td>';
echo $des;
echo '</td>';
echo '</tr>';
}
foreach ($price as $m)
{
echo '<tr>';
echo '<td>';
echo $m;
echo '</td>';
echo '</tr>';
}
?>