개발 꿀팁/PHP

PHP를 이용하여 간단한 양식을 작성하다

Jammie 2022. 7. 4. 13:17
반응형
//투기적 기교형
<?php
	/*echo "
		<table border=1 cellspacing=0 width=400 height=300> 
			<tr>
				<td>1</td>
				<td>2</td>
				<td>3</td>
				<td>4</td>
			</tr>
			<tr>
				<td>2</td>
				<td></td>
				<td></td>
				<td></td>
			</tr>
			<tr>
				<td>3</td>
				<td></td>
				<td></td>
				<td></td>
			</tr>
			<tr>
				<td>4</td>
				<td></td>
				<td></td>
				<td></td>
			</tr>
		</table>";*/
?>

//이용순환형
<?php
	$table="<table border='1' cellspacing='0'  width='400' height='300' text-align='center'>";
	for($i=1;$i<=4;$i++){ //行
		$table.="<tr>";
			for($j=0;$j<4;$j++){//列
				$table.="<td></td>";
			}
		$table.="</tr>";
	}
	$table.="</table>";
	echo $table;
?>

가공하다:

<?php
	$table="<table border='1' cellspacing='0'  width='400' height='300'>";
	for($i=1;$i<=6;$i++){ //行
		$table.="<tr align='center'>";
			for($j=0;$j<5;$j++){//列
				$table.="<td></td>";
			}
		$table.="</tr>";
	}
	echo $table;
	echo "표 ①"	
?>
<?php
	function getTable($a,$b){
	$table="<table border='1' cellspacing='0'  width='400' height='300'>";
	for($i=1;$i<=$a;$i++){ //行
		$table.="<tr align='center'>";
			for($j=0;$j<$b;$j++){//列
				$table.="<td></td>";
			}
		$table.="</tr>";
	}
	echo $table;
	echo "표 ①";
	}
	getTable(6,6);
?>
반응형