2013-10-03 92 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;