0.php
#표만드는 예제
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center> </td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
1.php
#이차원 배열에 숫자넣기
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=0;$x<=6;$x++){
$a[$y][$x]=$cnt++;
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
2.php
#대각선 가로로 왼쪽에만 숫자넣기
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<title>제목</title>
</head>
<body>
<table border="1" width="350" height="50">
<?
$cnt=1;
for($y=0; $y<=6; $y++){
for($x=0;$x<=$y;$x++){
$a[$y][$x]=$cnt++;
}
}
for($y=0; $y<=6; $y++){
echo "<tr height=40> ";
for($x=0;$x<7;$x++){
echo "<td width=40 align=center>";
if($a[$y][$x] != 0){
echo $a[$y][$x];
}else {
echo " ";
}
echo"</td>";
}
echo "</tr>";
}
?>
</table>
<script type="text/javascript">
</script>
</body>
</html>
'이전것 > 개발' 카테고리의 다른 글
php -> cross array (0) | 2016.07.06 |
---|---|
php -> two-dimensional arrays (0) | 2016.07.06 |
HTML5 (3) 로그인 폼 (0) | 2016.07.05 |
HTML5 (2) (0) | 2016.07.05 |
HTML5 (0) | 2016.07.04 |