7月11日

、在PHP中将九九乘法口诀表分别用table和div来显示出来

1.用table来显现:

<?php
function Create_Multiplication_formulas_in_Table() {
	$cellss = array ();
	for($i = 0; $i < 9; $i ++) {
		$cellss [$i] = array ();
	}
	for($i = 1; $i <= 9; $i ++) {
		for($j = 1; $j <= $i; $j ++) {
			
			$cellss [$i - 1] [$j - 1] = "$i*$j=" . $i * $j . " ";
		}
	}
	return $cellss;
}

$cells = Create_Multiplication_formulas_in_Table ();
function ShowTable($cellss) {
	echo "<table cellpadding=10 border=1 > ";
	foreach ( $cellss as $cell ) {
		echo "<tr >";
		foreach ( $cell as $value ) {
			echo "<td align=left>";
			echo " $value";
			echo "</td>";
		}
		echo "</tr>";
	}
	echo "</table>";
}

ShowTable ( $cells );

?>

2.用div来显现:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>乘法口诀表</title>
</head>
<style>
.box
{
	width:3000px;
	height:300px;
}
.faceul
{
	height:17px;
	display:block;
}
.faceul li
{
	list-style-type:none;
}
.faceul li span
{
	float:left;
	margin-left:10px;
	display:block;
}
</style>
<body>
<?php
function CreateMultiplicationformulasinTable() {
	$cellss = array ();
	for($i = 0; $i < 9; $i ++) {
		$cellss [$i] = array ();
	}
	for($i = 1; $i <= 9; $i ++) {
		for($j = 1; $j <= $i; $j ++) {
				
			$cellss [$i - 1] [$j - 1] = "$i*$j=" . $i * $j . " ";
		}
	}
	return $cellss;
}

$cells = CreateMultiplicationformulasinTable ();

function showDiv($cellss)
{
	echo "<div class='box'>";
	foreach ($cellss as $cell)
	{
		echo "<ul class='faceul'>";
		foreach ($cell as $value)
		{
			echo "<li>";
			echo "<span>";
			echo " $value";
			echo "</span>";
			echo "</li>";
		}
		echo "</ul>";
	}	
}

showDiv($cells);
?>
</body>
</html>

两种不同的显示效果如下;


*注:1.对于php来说一般一个函数只实现一个功能;

     2.对于zend studio 来说ctrl+shift+F可以实现自动排版功能

、对于写一个页面可以使用960.gs来进行css布局

这是960.gs网站,在上面可以下载

下载

对于如何使用960gs下面有一篇文章对此做了详细的的解释,我在次就不废话了。

960gs分析

作为一个初学者,我发现如果写一个页面没有用例如960gs来布局,自己硬写就会非常的麻烦代码一多就会出现混乱。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值