-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge29.php
More file actions
48 lines (37 loc) · 1.2 KB
/
Copy pathchallenge29.php
File metadata and controls
48 lines (37 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!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>Untitled Document</title>
</head>
<body>
<form action="challenge29.php" method="post" name="form">
<p>type list in using commas to separate values and a semi colon to make a new line. Example: row1Item1, row1Item2, row1lastitem; row2FirstItem, row2SecondItem; row3FirstItem, row3SecondItem, row3ThirdItem, row4FourthItem; row5FirstItem</p>
<textarea name="textarea" id="textarea" cols="60" rows="10"></textarea><br />
<input name="tablemaker" type="submit" id="submitbutton" value="Make Table" />
</form>
<?php
function createTable()
{
$submitted_data = $_POST['textarea'];
echo "<table border = '1'>\n";
$each_row = split(";", $submitted_data); //$each_row is now an array of however many elements
foreach($each_row as $row)
{
echo "<tr>\n";
$each_item = split(",", $row);
foreach($each_item as $item)
{
echo "<td>$item</td>";
}
echo "\n</tr>\n";
}
echo "</table>";
}
if(isset($_POST['tablemaker']))
{
createTable();
}
?>
</body>
</html>