skip to main
|
skip to sidebar
MR.FREEMAN
Home
About
Posts RSS
Comments RSS
Contact
Blogger Templates
Generate Table in HTML and PHP
Now I'll to tell you about how to create Table
at the first time, create new HTML file this is the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><br /><title>Generate Table in HTML and PHP</title><br /></head><br /><body><br /><h3 align="center">Generate Table in HTML and PHP</h3><br /><br /><form name="frmtabel" method="post" action="tbl.php"><br /><div align="center"><br />Row:<br /><input name="baris" type="text" id="baris" onkeyup="getmax();" onfocus="this.select();"><br /><br /><br />Column:<br /><input name="kolom" type="text" id="kolom" onkeyup="getmax();" onfocus="this.select();"><br /><br /><br />Sel :<br /><input name="sel" type="text" id="sel" onkeyup="getmax();" onfocus="this.select();"><br /><br /><br /><br /><br /><input name="enter" type="submit" value="Generate"><br/><br /><br/><input name="reset" type="reset" value="Reset"><br/><br /></div><br /></form><br /></body><br /><script language="JavaScript" type="text/javascript"><br /><!--<br />function getmax() {<br />var myForm = document.frmtabel;<br />var B = eval(myForm.baris.value);<br />var K = eval(myForm.kolom.value);<br />var S = eval(myForm.sel.value);<br />var cellmax = myForm.maks;<br />var total = 'N/A';<br />total = B * K;<br />cellmax.value = new String(total);<br />if (S > total)<br />{<br />alert('your input is too big, Max cell value = ' + total);<br />myForm.total.value = new String();<br />}<br />}<br />//--><br /></script><br /></html><br />
after that, create a PHP file, give name to thisi php file: tbl.php
this is the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><br /><br /><html><br /><br /><br /><br /><head><br /><br /><title>Generate Table Result</title><br /><br /></head><br /><br /><br /><br /><body><br /><br /><div align="center"><br /><br /><?php<br /><br />$rows = 1;<br /><br />$columns = 1;<br /><br />$cells = 1;<br /><br />?><br /><br /><br /><br /><?php $rows = (int) $_POST["baris"]; ?><br /><br /><?php $columns = (int) $_POST["kolom"]; ?><br /><br /><?php $cells = (int) $_POST["sel"]; ?><br /><br /><br /><br /><br /><br /><br /><strong>Row</strong> <?php echo $rows; ?> <em>rows</em><br /><br /><br /><strong>Column</strong> <?php echo $columns; ?> <em>columns</em><br /><br /><br /><strong>Cell</strong> <?php echo $cells; ?> <em>cells</em><br /><br /><br /><br /><br /><br /><strong>Generate Table</strong><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><?php<br /><br />$width = $columns * 80;<br /><br />echo "<table width=".$width." border="2">";<br /><br />$ro = 0;<br /><br />$cel = 1;<br /><br />while ($ro < $rows && $cel <= $cells)<br /><br />{<br /><br />echo "<tr>";<br /><br />$co = 0;<br /><br />while ($co < $columns)<br /><br />{<br /><br />if ($cel <= $cells)<br /><br />{<br /><br />echo "<td><div align="center">".$cel."</div></td>";<br /><br />$cel++;<br /><br />}<br /><br />$co++;<br /><br />}<br /><br />echo "</tr>";<br /><br />$ro++;<br /><br />}<br /><br />echo "</table>";<br /><br />?><br /><br /><br /><br /></div><br /><br /></body><br /><br /></html>
Newer Post
Older Post
Home
My Twitter
Chat
Blog Archive
►
2011
(3)
►
April
(3)
▼
2010
(20)
▼
April
(2)
Create Simple Login Form in PHP without Database
Generate Table in HTML and PHP
►
March
(14)
►
February
(4)
►
2009
(2)
►
June
(2)
Labels
Cinta
(1)
Gita Gutawa
(2)
Internet
(4)
Keamanan Sistem Komputer
(2)
Kuliah
(2)
Lirik
(1)
Pendidikan
(4)
PTI478
(10)
Rekayasa Perangkat Lunak
(1)
Tutorial Photoshop
(1)
Web Programming
(12)
Widgeo
widgeo.net