Home  >  Article  >  Backend Development  >  表格颜色有关问题。新手

表格颜色有关问题。新手

WBOY
WBOYOriginal
2016-06-13 11:51:39873browse

表格颜色问题。新手
这是我刚打的代码,原本想是一行黄色一行无色,可不知怎么回事变成全黄的了,大家帮我看看

<table border="1"><br /><?php<br />for($i=1; $i<=9; $i++)<br />{<br />	for($n=1; $n<9; $n++)<br />	{<br />		if($n%2==0)<br />		{<br />			echo '<tr bgcolor="yellow">';<br />		}<br />		else<br />		{<br />			echo '</tr>';<br />		}<br />	}<br />	for($j=1; $j<=$i; $j++)<br />	{<br />		$c = $i * $j;<br />		echo "<td>".$j."*".$i."=".($i*$j)." <tt>"."<td>" ; <br />	}<br />	echo "<br>";<br />}<br />?>

------解决方案--------------------
<html><br /><body><br /><br />	<table border="1"><br />		<?php<br />		for($i=1; $i<=9; $i++)<br />		{<br />			<br />			if($i%2==0)<br />			{<br />				echo '<tr bgcolor="yellow">';<br />			}<br />			else<br />			{<br />				echo '</tr>';<br />			}<br />			<br />			for($j=1; $j<=$i; $j++)<br />			{<br />				$c = $i * $j;<br />				echo "<td>".$j."*".$i."=".($i*$j)." <tt>"."<td>" ; <br />			}<br />			echo "<br>";<br />		}<br />		?><br />	</table><br /></body><br /></html>

------解决方案--------------------
echo "
";造成的 吧这个去掉
------解决方案--------------------
标记不配套
echo '<table border="1">';<br /><br />for($i=1; $i<=9; $i++) {<br />    for($n=1; $n<9; $n++){<br />        if($i%2==0) {<br />            echo '<tr bgcolor="yellow">';<br />        }else {<br />            echo '<tr>';<br />        }<br />    }<br />    for($j=1; $j<=$i; $j++) {<br />        $c = $i * $j;<br />        echo "<td>".$j."*".$i."=".($i*$j)." </td>" ; <br />    }<br />    echo "</tr>";<br />}<br />echo '</table>';

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn