[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: this table in html how



On Sunday 07 March 2010 12:26:01 Adrian Levi wrote:
> On 7 March 2010 21:19, Thierry Chatelet <tchatelet@free.fr> wrote:
> 
> I get to correct you back :-)

Yes!!

> If your going to specify cols then the percentages need to match ;-)
> 
> Adrian
> 

This will be better (using php):
Choice of the number of rows
Choice of the percentage

To improve:
Need to get ride of the first row

Safe under table.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="fr" lang="fr">


<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Percentage table</title>
<link rel="stylesheet" media="screen" type="text/css" title="xxx" href="" />

<style>
body {
  background-color: #1BFFBB; /* (grille grise et blanche) */
  margin: 0px 0px; /* Donner plus de marge à gauche et à droite, et moins en 
haut et en bas */
  font-family: sans-serif; /* Police moderne, sans empattements, du type Times 
New Roman */
}

table /* Le tableau en lui-même */
{
   margin: auto; /* Centre le tableau */
   border: 0px; /* Bordure du tableau avec effet 3D (outset) */
   border-collapse: collapse; /* Colle les bordures entre elles */
}

td /* Les cellules normales */
{
   border: 1px solid black;
   text-align: center; /* Tous les textes des cellules seront centrés*/
/*   padding: 5px; /* Petite marge intérieure aux cellules pour éviter que le 
texte touche les bordures */
}

</style>
</head>

<body>


<?php
//--------- Prepare form for number of cells per row --------//
if (isset($_POST['Next1'])) {
	$TableWidth= $_POST['TableWidth'];
	$NbrRow= $_POST['NbrRow'];
}

//---------- Prepare form for value of each cell ---------------//
if (isset($_POST['Next2'])) {
	$TableWidth= $_POST['TableWidth'];
	$NbrRow= $_POST['NbrRow'];
	for ($i=1; $i< $NbrRow+1; $i++) {
		$NbrCellRow[$i]= $_POST['NbrCellRow'.$i];
	}

}

//----------Prepare form to display the table AT LAST -----------//
if (isset($_POST['Next3'])) {
	$TableWidth= $_POST['TableWidth'];
	$NbrRow= $_POST['NbrRow'];
	$BaseColumnWidth= round($TableWidth/100);
	$TableWidth= $BaseColumnWidth*100;
	for ($i=1; $i< $NbrRow+1; $i++) {
		$NbrCellRow[$i]= $_POST['NbrCellRow'.$i];
		for ($j=1; $j-1< $NbrCellRow[$i]; $j++) {
		 $NbrColSpan[$i][$j]= $_POST['ValueCell'.$j.'Row'.$i];
		}
	}
$ShowTable= True;
}

//------------------- Form -------------------------------//
echo '<form action="table.php" method="post"><br /><br />';

//-----Post TableWidth and Number of Rows -----------------//
	if (!isset($TableWidth)) {
		echo 'Tablewidth in pixel: <input type="text" 
name="TableWidth"></input><br/>';
		echo 'Number of rows: <input type="text" name="NbrRow"></input><br/>';
	echo '<input type="submit" name="Next1" value="Next"></input><br/>';
	}

//-----Post number of cells per row -----------------------//
	if (isset($TableWidth) AND !isset($NbrCellRow[1])) {
		echo '<input type="hidden" name="TableWidth" value="'.$TableWidth.'">';
		echo '<input type="hidden" name="NbrRow" value="'.$NbrRow.'">';
		for ($i=1; $i < $NbrRow+1; $i++) {
			echo 'Number of cells for row '.$i.': ';
			echo '<input type="text" name="NbrCellRow'.$i.'" size="4"></input><br/>';
		}
	echo '<input type="submit" name="Next2" value="Next"></input><br/>';
	}

//-----Post value of each cell -------------------------------------//
	if (isset ($_POST['Next2'])) {
		echo '<input type="hidden" name="TableWidth" value="'.$TableWidth.'">';
		echo '<input type="hidden" name="NbrRow" value="'.$NbrRow.'">';
		for ($i=1; $i < $NbrRow+1; $i++) {
			echo '<input type="hidden" name="NbrCellRow'.$i.'" value="'.
$NbrCellRow[$i].'">';
			echo 'Values for row '.$i.':<br/>';
			for ($j=1; $j < $NbrCellRow[$i]+1; $j++) {
				echo 'Value for cell '.$j.': ';
				echo '<input type="text" name="ValueCell'.$j.'Row'.$i.'" size="4"></input> 
%<br/>';
			}
		}
	echo '<input type="submit" name="Next3" value="Next"></input><br/>';
	
	}
	
// -------- Show Table ------------------------------------------------/
	if ($ShowTable== True) {
		echo '<table width="'.$TableWidth.'px">';
		echo '<tr>';
			for ($i=0; $i <100; $i++) {
				echo '<td width="'.$BaseColumnWidth.'"></td>';}
		echo '</tr>';
			for ($i=1; $i< $NbrRow+1; $i++) {
				echo '<tr>';
				for ($j=1; $j< $NbrCellRow[$i]+1; $j++) {
					echo '<td colspan="'.$NbrColSpan[$i][$j].'">R'.$i.'C'.$j.': '.
$NbrColSpan[$i][$j].'"%</td>';
				}
				echo '</tr>';
			}
		echo '</table>';
	}
echo '</form>';

?>
</body>

</html>


Reply to: