let say user key in a,b,c,d in the submit page, how to display the output as a in row 1 column 1, b in row 1 column 2, c in row 2 column 1 and d in row 2 column 2.
here is the code.
<?php
$input=$_POST['input'];
$inputexplode=explode(",",$input);
echo current($inputexplode);
echo next($inputexplode);
echo "Here are exploded words!"."<br/><br/>";
$result=count($inputexplode);
echo $result ."<br/>";
if ($result !=2 and $result>1){
ceil(sqrt($result));
$i=ceil(sqrt($result));
}
else{
floor(sqrt($result));
$i=floor(sqrt($result));
echo $i."<br/>";
}
echo "rownumber" ;
echo $i ."<br/>";
$k=0;
for($k=1; $k<=$i;$k++)
{
echo $inputexplode[$k];
}
$htmlStringForTable = '';
$htmlStringForTable = '<table border="1">' . "\n";
$rows=$i;
$cols =$i;
for($row = 1; $row <= $rows; $row++) {
$htmlStringForTable = $htmlStringForTable . '<tr>' . "\n";
for($col = 1; $col <= $cols; $col++) {
$htmlStringForTable = $htmlStringForTable . '<td>';
$htmlStringForTable = $htmlStringForTable . $inputexplode;
$htmlStringForTable = $htmlStringForTable . '</td>' . "\n";
}
}
$htmlStringForTable = $htmlStringForTable . '</table>';
//for ($k=0;$k<=$i;$k++)
// {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>
<?php echo $newTitle; ?>
</title>
<meta name="author" content="jinlu"><!-- Date: 2012-04-30 -->
</head>
<body>
<br/>
<a href="Ex2-3.php">Back to Explosion!</a><br />
<?php echo $htmlStringForTable; ?>
</body>
</html>
thanks