2013-10-03 143 views
-3

任何人都可以看到我搞亂了嗎?加載時代碼不會運行

我期待的輸出是一個78像素x 78像素的盒子,每個像素都有一個鏈接到另一個頁面,此刻只有第一個像素有效。

該代碼加載在頁面上,可以在圖像下看到,這是怎麼回事?

<html> 
<head> 

<title>Untitled Page</title> 

<style type="text/css"> 
#ImageMap1 
{ 
    border: 0px #000000 solid; 
} 
</style> 
</head> 
<body> 
<div id="wb_ImageMap1" style="position:absolute;left:0px;top:0px;width:600px;height:600px;z-index:0;"> 

<img src="images/black.bmp" id="ImageMap1" alt="" usemap="#ImageMap1_map" border="0" style="width:600px;height:600px;"> 

<map name="ImageMap1_map"> 
foreach ($string){ 
    $x = 1; $y = 1; $z = 1;$output = ''; 
    for($x=1;$x<79;$x++) 
    { 
    for($y=1;$y<79;$y++) 
    $string = $x .','.$y.','.$z; 
    $output .= '<area shape="circle" coords="'. $string . '" href="./index.html" target="_blank" alt="" yellow="">' 
    } 
    } 
    echo $output; 

</map> 
</div> 
</body> 
</html> 
+0

EER我加了一個PHP的標籤..但這個不是PHP? – mkoryak

+0

看起來像PHP給我。 –

回答

1

你需要用你的代碼的PHP標籤

<?php 
foreach ($string){ 
    $x = 1; $y = 1; $z = 1;$output = ''; 
    for($x=1;$x<79;$x++) 
    { 
    for($y=1;$y<79;$y++) 
    $string = $x .','.$y.','.$z; 
    $output .= '<area shape="circle" coords="'. $string . '" href="./index.html" target="_blank" alt="" yellow="">' 
    } 
    } 
    echo $output; 
?> 
0

您添加的代碼作爲僅僅是純文本,讓它由PHP執行,添加php標記。

如果php標籤存在,那麼只有服務器知道執行它並處理,否則它被認爲是純文本。

因此,使用這樣的:

foreach ($string){ 
$x = 1; $y = 1; $z = 1;$output = ''; 
for($x=1;$x<79;$x++) 
{ 
for($y=1;$y<79;$y++) 
$string = $x .','.$y.','.$z; 
$output .= '<area shape="circle" coords="'. $string . '" href="./index.html" target="_blank" alt="" yellow="">' 
} 
} 
echo $output;