Précédent   Forum des professionnels en informatique > PHP > Langage > Débuter
Débuter Forum d'entraide pour débuter en PHP. Avant de poster -> Cours PHP, FAQ PHP, Outils PHP, etc.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 02/01/2011, 12h49   #1
Débutant
 
Avatar de ETVigan
 
Homme Esteban
Conseil - Consultant en systèmes d'information
Inscription : avril 2010
Messages : 632
Détails du profil
Informations personnelles :
Nom : Homme Esteban
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Conseil - Consultant en systèmes d'information
Secteur : Finance

Informations forums :
Inscription : avril 2010
Messages : 632
Points : 122
Points : 122
Envoyer un message via MSN à ETVigan Envoyer un message via Skype™ à ETVigan
Par défaut Problèmes de classe TABLE

Tout d'abord, meilleurs voeux pour 2011...

J'ai un souci dans une classe Table reprise d'autre part et déjà adaptée profondément...

La voici (ma version):

Code :
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
$style = array("design" => "" , "title" =>	"" , "td" => "" , "tr" => "" , "table" => "" ) ;

class tableDesign
{
	private $id_container, $width, $cols, $table_title, $class_design, $class_title, $class_td, $class_tr, $class_table ;
	
	function __construct(	$id_container="", 		// If table sould be contained in <div id="conainer"
							$id_style		,
							$width
						)
	{	$this->id_container = $id_container;
		$this->cols			= count($width) ;
		$this->width        = $width ;
	
		foreach ($id_style as $key => $val)
		{	switch($key)
			{	case "design": 	$this->class_design = $val ;
								break ;
				case "title" :	$this->class_title  = $val ;
								break ;
				case "td"	 :	$this->class_td     = $val ;
								break ;
				case "tr"	 :  $this->class_tr     = $val ;
								break ;
				case "table" :  $this->class_table  = $val ;
								break ;
				default  	 :  user_error("Bad value for style" , E_USER_ERROR) ;
			}
		}
	}
	
	function getClassTag($node,$width=0)
	{	switch($node)
		{	case "design":	return ($this->class_design !="" ?" class=\"".$this->class_design."\"" : "") ;
							break;
			
			case "title":	return ($this->class_title != "" ? " class=\"".$this->class_title."\"" : "") ;
							break;
			
			case "td":		return ($this->class_td    != "" ? " class=\"".$this->class_td."\" width=\"".$width."\"" : "") ;
							break;
			
			case "tr":		return ($this->class_tr    != "" ? " class=\"".$this->class_tr."\"" : "") ;
							break;
			
			case "table":	return ($this->class_table != "" ? " class=\"".$this->class_table."\"" : "" ) ;
							break;
			
			default: 		return ""; 
							break;
		}
	}
	
	function addRow($rows)
	{	if ($this->cols == count($rows) )
			$this->data[] = $rows ;
		else
			user_error("Invalid Column count in AddRow function" , E_USER_ERROR) ;
	}
	
	function addImage($image,$border,$title)
	{	 //$this->data[] = "<img src=\"images/gplv3.png\" border=0 title=\"NEW\" />" ;
	}
	
	function display()
	{	$tb = "";
//
//		Print HTML code
//		===============
		if ($this->id_container != "")
			$tb .= "<div id=\"".$this->id_container."\">\n";
		
		$tb .= "<table".$this->getClassTag("table").">\n";
//
		foreach ($this->data as $row => $data)
		{	$tb .= "<tr".$this->getClassTag("tr").">\n";
			$col = 0 ;
			foreach($data as $key => $cell)
			{ 	if ($cell == "")
==>81			     	$cell = "$nbsp;" ;
				$tb .= "<td".$this->getClassTag("td",$this->width[$col++]).">".$cell."</td>\n";
			}
			$tb .= "</tr>\n";
		}
		$tb .= "</table>\n";
		
		if ($this->id_container != "")
			$tb .= "</div>\n";
//
//		End of printing
//		===============		
		echo $tb .= "\n";
	}
}

?>
En 81, j'ai le msg dans le log.php: Undefined variable: nbsp in F:\WebSites\table\class\tableDesign.php on line 81 et pourtant; je suis persuadé de n'avoir rien modifié.... mais surement pas vrai !

81 EST CORRIGE !

Que j'utilise ainsi:

Code :
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
 
<!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>Test table</title>
 
<style type="text/css">
#title{
cursor:pointer;
}
.design{
font-weight:bold;
}
 
.td{
	border:1px solid black;
	text-align:center;
	padding:0px;
	margin: 0px;
}
 
.table  {
	border-collapse: collapse;
    border:0px;
    margin: 0px;
    padding: 0px;
}
 
.row  {
	color:red;
}
 
</style>
 
</head>
 
<body>
 
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/class/tableDesign.php" ;
//
define("dir_image" , "images" ) ;
 
$style = array("design" => "design" , "title" => "title" , "td" => "td" , "tr" => "tr" , "table" => "table" ) ;
 
class Image extends tabledesign
{	private $directory, $name, $width, $height, $title ;
 
	function __constructor($directory, $name, $width, $height , $title)
	{	$this->directory = $directory ;
		$this->name 	 = $name ;
		$this->width 	 = $width ;
		$this->height 	 = $height ;
		$this->title 	 = $title ;
	}
 
	function __destructor()
	{}
 
	function display()
	{	print( "<img src=\"images/paysviganais.jpg\" border=0  width=\"113\" height=\"113\" title=\"NEW\" />" ) ;
	}
}
 
$tb = new tableDesign(	"content",	$style , array(113,750,141)	);
 
$row1 	= array(	"<img src=\"images/paysviganais.jpg\" border=0  width=\"113\" height=\"113\" title=\"Le pays Viganais\" />",
					"<img src=\"images/banniere.jpg\" border=0  width=\"750\" height=\"113\" title=\"Les Cimes\" />",
					"<img src=\"images/ETVictor.jpg\" border=0  width=\"141\" height=\"113\" title=\"Moi & Victor\" />"
				) ;
$row2 	= array(	"<img src=\"images/new.gif\" border=0 title=\"NEW\" />" ,
					"<img src=\"images/del'aigoual.jpg\" border=0 width=\"750\" height=\"113\" title=\"Le mont Aiguoal\" />" ,
					"Row1 Col2" 
                ) ;
 
$row3	= array(	"<img src=\"images/new.gif\" border=0 title=\"NEW\" />" ,
					"Row2 Col1" ,
					"Row3 Col2"
				) ;
 
$row4	= array(	//"<img src=\"images/gplv3.png\" border=0 title=\"NEW\" />",
					$tb->addImage("images/gplv3.png",0,"title") ,
					"Esteban"  ,
					"Victor."
				) ;
 
$tb->addRow($row1) ;
$tb->addRow($row2) ;
$tb->addRow($row3) ;
$tb->addRow($row4) ;
 
$tb->display();
?>
</body>
</html>
Les changements apportés permettre d'avoir:

Code :
1
2
<td class="td" width="123">
Ce qui me permettra de traiter le colspan ultérieurement...

Que souhaiterais-je ajouter:

1) Il n'est pas rare d'avoir des tables imbriquées...
Donc inclure dans une cellule un autre script PHP

2) Pouvoir faire le "merge" de plusieurs colonnes mais là je suis proche d'une solution.

3) la méthode addImage ne donne pas (pour le moment) les résultats escomptés mais peut mieux faire

Mais toutes les idées qui viennent seront les bienvenues....

Ce n'est pas de trop pour le mal de crane ambiant.... ?
__________________
Esteban
ETVigan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2011, 13h36   #2
Membre Expert
 
Avatar de gwinyam
 
Homme Mathieu ROBIN
Développeur Web
Inscription : mai 2006
Messages : 1 116
Détails du profil
Informations personnelles :
Nom : Homme Mathieu ROBIN
Âge : 25
Localisation : France, Paris (Île de France)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mai 2006
Messages : 1 116
Points : 2 142
Points : 2 142
Pour ton premier point, l'idée d'inclure du code PHP, ok. Mais t'as plus simple je pense, enfin plus simple, façon de parler.
Si tu dois pouvoir gérer que parfois une cellule contient une table, tu te retrouves plus ou moins dans le cas de figure du pattern Composite: http://fr.wikipedia.org/wiki/Objet_composite

Pour la méthode image, déjà toute valeur d'attribut nécessite d'être entourée par des quotes. En plus la solution du border="0" est pas super propre. Un peu de CSS, ça allégera ton code en le rendant plus propre.
__________________
Mon blog techno et son billet hebdomadaire sur l'actualité jQuery. Et mon blog cuisine pour une personne.
Le bouton ne masse pas les pieds, mais ça aide la communauté.
gwinyam est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2011, 14h45   #3
Débutant
 
Avatar de ETVigan
 
Homme Esteban
Conseil - Consultant en systèmes d'information
Inscription : avril 2010
Messages : 632
Détails du profil
Informations personnelles :
Nom : Homme Esteban
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Conseil - Consultant en systèmes d'information
Secteur : Finance

Informations forums :
Inscription : avril 2010
Messages : 632
Points : 122
Points : 122
Envoyer un message via MSN à ETVigan Envoyer un message via Skype™ à ETVigan
Par défaut Problème de classe DATE

Mathieu,

Merci d'abord pour ton intervention.
Etant ex-informaticien, je comprends l'article de Wikipedia mais dès qu'on passe à du PHP, là je dérape... et ne vois pas où je mets les pieds !
Et le rapport entre le code propose et mes socis:
Voiici le code en question:

Code :
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
 
<?php
class Component
{
 
  // Attributes
  private $basePath;	
  private $name;
  private $parent;
 
  public function __construct($name, CDirectory $parent = null)
  {
    // Debug : echo "constructor Component";
    $this->name = $name;
    $this->parent = $parent;
    if($this->parent != null)
    {
       $this->parent->addChild($this);
       $this->basePath = $this->parent->getPath();
    }
    else
    {
      $this->basePath = '';			
    }
  }
 
 
  // Getters	
  public function getBasePath() { return $this->basePath; }
  public function getName() { return $this->name; }
  public function getParent() { return $this->parent; }
 
  // Setters
  public function setBasePath($basePath) { $this->basePath = $basePath; }
  public function setName($name) { $this->name = $name; }
  public function setParent(CDirectory $parent) { $this->parent = $parent; }
 
  // Method
  public function getPath() { return $this->getBasePath().'/'.$this->getName(); }
}
 
class CFile extends Component
{
 
  // Attributes
  private $type;
 
 
  public function __construct($name, $type, CDirectory $parent = null)
  {
    // Debug : echo "constructor CFile";
    $this->type = $type;
 
    // Retrieve constructor of Component
    parent::__construct($name, $parent);	
  }
 
  // Getters	
  public function getType() { return $this->type; }
 
  // Setters
  public function setType($type) { $this->type = $type; }
 
  // Methods of Component class
  public function getName() { return parent::getName().'.'.$this->getType();
  public function getPath() { return parent::getPath().'.'.$this->getType(); }
}
 
class CDirectory extends Component
{
 
  // Attributes
  private $childs;
 
  public function __construct($name, CDirectory $parent = null)
  {
    // Debug : echo "constructor CDirectory";
    $this->childs = array();
 
    // Retrieve constructor of Component
    parent::__construct($name, $parent);
  }
 
  // Getters	
  public function getChilds() { return $this->childs; }
 
  // Setters
  public function setChilds($childs) { $this->childs = $childs; }
 
 
  // Methods
  public function addChild(Component $child)
  {
    $child->setParent($this);
    $this->childs[] = $child;
  }
 
  public function showChildsTree($level = 0)
  {
    echo "<br/>".str_repeat('&nbsp;', $level).$this->getName();
    foreach($this->getChilds() as $child)
    {
      if($child instanceof self)
      {
        $child->showChildsTree($level+1);
      }
      else
      {
        echo "<br/>".str_repeat('&nbsp;', $level+1).$child->getName();
      }	
    }
  }
}
?>
Exemple d'utilisation (example of use):
<?php
$root = new CDirectory('root');
$dir1 = new CDirectory('dir1', $root);
$dir2 = new CDirectory('dir2', $root);
$dir3 = new CDirectory('dir3', $root);
$dir4 = new CDirectory('dir4', $dir2);
$file1 = new CFile('file1','txt', $dir1);
$file2 = new CFile('doc', 'pdf', $dir4);
 
$root->showChildsTree();
?>
Je ne parviens pas à faire la translation entre ces classes et la mienne (à supposer qu'elle soit +/- correcte)

Ma classe est:

Code :
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
 
a<?php
$style = array("design" => "" , "title" =>	"" , "td" => "" , "tr" => "" , "table" => "" ) ;
 
class tableDesign
{
	private $id_container, $width, $cols, $table_title, $class_design, $class_title, $class_td, $class_tr, $class_table ;
 
	function __construct(	$id_container="", 		// If table sould be contained in <div id="conainer"
							$id_style		,
							$width
						)
	{	$this->id_container = $id_container;
		$this->cols			= count($width) ;
		$this->width        = $width ;
 
		foreach ($id_style as $key => $val)
		{	switch($key)
			{	case "design": 	$this->class_design = $val ;
								break ;
				case "title" :	$this->class_title  = $val ;
								break ;
				case "td"	 :	$this->class_td     = $val ;
								break ;
				case "tr"	 :  $this->class_tr     = $val ;
								break ;
				case "table" :  $this->class_table  = $val ;
								break ;
				default  	 :  user_error("Bad value for style" , E_USER_ERROR) ;
			}
		}
	}
 
	function getClassTag($node,$width=0)
	{	switch($node)
		{	case "design":	return ($this->class_design !="" ?" class=\"".$this->class_design."\"" : "") ;
							break;
 
			case "title":	return ($this->class_title != "" ? " class=\"".$this->class_title."\"" : "") ;
							break;
 
			case "td":		return ($this->class_td    != "" ? " class=\"".$this->class_td."\" width=\"".$width."\"" : "") ;
							break;
 
			case "tr":		return ($this->class_tr    != "" ? " class=\"".$this->class_tr."\"" : "") ;
							break;
 
			case "table":	return ($this->class_table != "" ? " class=\"".$this->class_table."\"" : "" ) ;
							break;
 
			default: 		return ""; 
							break;
		}
	}
 
	function addRow($rows)
	{	if ($this->cols == count($rows) )
			$this->data[] = $rows ;
		else
			user_error("Invalid Column count in AddRow function" , E_USER_ERROR) ;
	}
 
	function addImage($image,$border,$title)
	{	 //$this->data[] = "<img src=\"images/gplv3.png\" border=0 title=\"NEW\" />" ;
	}
 
	function display()
	{	$tb = "";
//
//		Print HTML code
//		===============
		if ($this->id_container != "")
			$tb .= "<div id=\"".$this->id_container."\">\n";
 
		$tb .= "<table".$this->getClassTag("table").">\n";
//
		foreach ($this->data as $row => $data)
		{	$tb .= "<tr".$this->getClassTag("tr").">\n";
			$col = 0 ;
			foreach($data as $key => $cell)
			{ 	if (empty($cell))
			     	$cell = "&nbsp;" ;
				$tb .= "<td".$this->getClassTag("td",$this->width[$col++]).">".$cell."</td>\n";
			}
			$tb .= "</tr>\n";
		}
		$tb .= "</table>\n";
 
		if ($this->id_container != "")
			$tb .= "</div>\n";
//
//		End of printing
//		===============		
		echo $tb .= "\n";
	}
}
 
?>
J'ai besoin d'être pris par la main là, dsl de dire cela, ce n'est peut être pas votre rôle mais cela dépasse un peu mes compétences, je vais passer la soirée la dessus et aviser....

Merci tout de même
__________________
Esteban
ETVigan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2011, 15h07   #4
Membre Expert
 
Avatar de gwinyam
 
Homme Mathieu ROBIN
Développeur Web
Inscription : mai 2006
Messages : 1 116
Détails du profil
Informations personnelles :
Nom : Homme Mathieu ROBIN
Âge : 25
Localisation : France, Paris (Île de France)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mai 2006
Messages : 1 116
Points : 2 142
Points : 2 142
Je pense que j'ai été trop rapide en proposant le Composite. Voilà ce que je te propose pour gérer ça :

Code php :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
class tableDesign
{
[...]
/*
 * Remplaçons
 * $tb .= "<td".$this->getClassTag("td",$this->width[$col++]).">".$cell."</td>\n";
 * par
*/
$tb .= "<td".$this->getClassTag("td",$this->width[$col++]).">";
if($cell instanceof tableDesign)
  $tb .= $cell->display();
else
  $tb .= $cell;
$tb .= "</td>\n";
[...]
}
Bon après comment gérer l'instanciation de l'objet, je sais pas trop, j'ai pas regardé ton code dans le détail etc. Mais l'idée est là

Au passage, merci de me tutoyer, le vouvoiement me met mal à l'aise Et je suis ici pour aider justement (sans faire les devoirs des plus jeunes évidement, mais bon ça ça ne ressemble pas à un devoir) .
__________________
Mon blog techno et son billet hebdomadaire sur l'actualité jQuery. Et mon blog cuisine pour une personne.
Le bouton ne masse pas les pieds, mais ça aide la communauté.
gwinyam est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/01/2011, 15h11   #5
Débutant
 
Avatar de ETVigan
 
Homme Esteban
Conseil - Consultant en systèmes d'information
Inscription : avril 2010
Messages : 632
Détails du profil
Informations personnelles :
Nom : Homme Esteban
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Conseil - Consultant en systèmes d'information
Secteur : Finance

Informations forums :
Inscription : avril 2010
Messages : 632
Points : 122
Points : 122
Envoyer un message via MSN à ETVigan Envoyer un message via Skype™ à ETVigan
Merci mais étant belge et non français, le tutoiement est NATUREL....
Je regarde ta suggestion de tout prêt...

CELA DONNE DEJA LE MEME RESULTAT.....



Je te ferais un schéma de ce que je souhaite en fin d'aprèm et avec cela je souhaiterai que tu regardes si ton modèle de données "Composite" peut s"arranger avec ou sans quelques modifs...
Es-tu OK pour le principe ?

Merci d'envisager...

Bonsoir gwinyam,

Merci de bien vouloir te pencher sur mon prob !
Ma classe Tabledesign et tout le code que vous avez en POST génère l'HTML suivant:

Code :
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
<div id="content">
<table class="table">
<tr class="tr">

<td class="td" width="113">A</td>
<td class="td" width="750">&nbsp;</td>
<td class="td" width="141">&nbsp;</td>
</tr>
<tr class="tr">
<td class="td" width="113"><img src="images/paysviganais.jpg" border=0  width="113" height="113" title="Le pays Viganais" /></td>
<td class="td" width="750"><img src="images/banniere.jpg" border=0  width="750" height="113" title="Les Cimes" /></td>
<td class="td" width="141"><img src="images/ETVictor.jpg" border=0  width="141" height="113" title="Moi & Victor" /></td>
</tr>
<tr class="tr">
<td class="td" width="113"><img src="images/new.gif" border=0 title="NEW" /></td>
<td class="td" width="750"><img src="images/del'aigoual.jpg" border=0 width="750" height="113" title="Le mont Aiguoal" /></td>
<td class="td" width="141">Row1 Col2</td>
</tr>
<tr class="tr">

<td class="td" width="113"><img src="images/new.gif" border=0 title="NEW" /></td>
<td class="td" width="750">Row2 Col1</td>
<td class="td" width="141">Row3 Col2</td>
</tr>
<tr class="tr">
<td class="td" width="113">&nbsp;</td>
<td class="td" width="750">Esteban</td>
<td class="td" width="141">Victor.</td>
</tr>
</table>
</div>
Le gros problème que j'ai est que la cellule Row1 Col2 qui devrait être autre table avec du code jscript pour AddGoogle...

En fait, chaque cellule est susceptible de recevoir du code, mais quel code ?.
Si HTML, cela va... même si je n'ai encore résolu mon AddImage...
Si PHP cela pose le problème du moment de l'interprétation du PHP... la récursivité existe... est ce la solution ? Pas sur, ton modèle de donnée me semble à 1ère vue peut être +approprié....

Les autres problèmes sont - je crois - à ma portée, càd, gestion des CSS et le COLSPAN....

Je ne pense pas et - que je sache - je n’utilise pas le ROWSPAN.
Cela tombe - à mon avis - dans la résolution de table imbriquée !

Voilà en gros ma problématique.
Demain, ne bouge pas sauf pour sortir mon chien mais 100% PHP

@demain ?

Esteban

Bonsoir gwinyam,

Merci de bien vouloir te pencher sur mon prob !
Ma classe Tabledesign et tout le code que vous avez en POST génère l'HTML suivant:

Code :
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
<div id="content">
<table class="table">
<tr class="tr">

<td class="td" width="113">A</td>
<td class="td" width="750">&nbsp;</td>
<td class="td" width="141">&nbsp;</td>
</tr>
<tr class="tr">
<td class="td" width="113"><img src="images/paysviganais.jpg" border=0  width="113" height="113" title="Le pays Viganais" /></td>
<td class="td" width="750"><img src="images/banniere.jpg" border=0  width="750" height="113" title="Les Cimes" /></td>
<td class="td" width="141"><img src="images/ETVictor.jpg" border=0  width="141" height="113" title="Moi & Victor" /></td>
</tr>
<tr class="tr">
<td class="td" width="113"><img src="images/new.gif" border=0 title="NEW" /></td>
<td class="td" width="750"><img src="images/del'aigoual.jpg" border=0 width="750" height="113" title="Le mont Aiguoal" /></td>
<td class="td" width="141">Row1 Col2</td>
</tr>
<tr class="tr">

<td class="td" width="113"><img src="images/new.gif" border=0 title="NEW" /></td>
<td class="td" width="750">Row2 Col1</td>
<td class="td" width="141">Row3 Col2</td>
</tr>
<tr class="tr">
<td class="td" width="113">&nbsp;</td>
<td class="td" width="750">Esteban</td>
<td class="td" width="141">Victor.</td>
</tr>
</table>
</div>
Le gros problème que j'ai est que la cellule Row1 Col2 qui devrait être autre table avec du code jscript pour AddGoogle...

En fait, chaque cellule est susceptible de recevoir du code, mais quel code ?.
Si HTML, cela va... même si je n'ai encore résolu mon AddImage...
Si PHP cela pose le problème du moment de l'interprétation du PHP... la récursivité existe... est ce la solution ? Pas sur, ton modèle de donnée me semble à 1ère vue peut être +approprié....

Les autres problèmes sont - je crois - à ma portée, càd, gestion des CSS et le COLSPAN....

Je ne pense pas et - que je sache - je n’utilise pas le ROWSPAN.
Cela tombe - à mon avis - dans la résolution de table imbriquée !

Voilà en gros ma problématique.
Demain, ne bouge pas sauf pour sortir mon chien mais 100% PHP

@demain ?

Esteban

Voici le code la cell Row1 Col2 appelé par require_once (souvent utilisé)

Code :
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
 
<table cellspacing="0" cellpadding="0" class="adsense">
  <tr height="2">
    <td width="10">&nbsp;</td>
    <td width="125">&nbsp;</td>
    <td width="10">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
		<script type="text/javascript">
		<!--
			google_ad_client = "pub-0373415130600157";
			/* 120x600, date de cration 05/09/09 */
			google_ad_slot = "4717722336";
			google_ad_width = 120;
			google_ad_height = 600;
		//-->
		</script>
 
		<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
		</script>    
	<td>&nbsp;</td>
  </tr>
  <tr height="2">
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
Encore merci

Voici u exemple + complet, le squelette de mon site...
Code :
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
 
<?php
// =============================================================================================================================== //
require_once $_SERVER['DOCUMENT_ROOT'] .  "/class/define/equate.php";       
$debug_myPage = true ;
// =============================================================================================================================== //
?>
<!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>
	<link href="../css/jecrapahute.css" rel="stylesheet" type="text/css"/>
<?php
/**
* Inclusion metatags
*
*/
 	$pattern = $_SERVER['DOCUMENT_ROOT'] . "/metatags/" ;
	if (isset( $_SESSION[SCREEN] ) )
		{	$file = $pattern . $_SESSION[SCREEN] . ".php" ;
			if (!file_exists($file))
                { 	$file = $pattern . "index.php" ;
					user_error("Substition made for missing METATAGS[".$_SESSION[SCREEN]." - INDEX used ]" , E_USER_WARNING) ;
				}
		}
	else
		{	$file = $pattern . "index.php" ;
			user_error("Substition made for missing METATAGS[ INDEX used ]" , E_USER_WARNING) ;
		}
	require_once $file ;
// =============================================================================================================================== //
?>
	<title><?php if (isset($_SESSION[SITE])) echo $_SESSION[SITE]  ?></title>
</head>
 
 
 
<style type="text/css">
<!--
body,td,th,tr {
	font-family: Verdana, Arial, Helvetica, sans-serif;
}
body {
	background-color: #FF00FF;
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 1004px;
}
-->
</style>
<body class="body">
<!-- ================================================ -->
<!--       Ancre pour retour au sommet de la page     -->
<!-- ================================================ -->
<a name="Top" id="Top"></a>
 
<!-- ============================================================================================================================ -->
<!--       Bannire horisontale                                                                                                   -->
<!-- ============================================================================================================================ -->
<table cellspacing="0" cellpadding="0" width="1004">
<!-- ============================================================================================================================ -->
<!--       Page de SIGNON                                                                                                         -->
<!-- ============================================================================================================================ -->
<tr>
    <td rowspan="2" class="signon">
		<?php 
			require_once $_SERVER['DOCUMENT_ROOT'] .  "/includes/signon.php";       
		?>	
	</td>
</tr>
</table>
<!-- ============================================================================================================================ -->
<!--       Bannière horisontale                                                                                                   -->
<!-- ============================================================================================================================ -->
<table cellspacing="0" cellpadding="0">
<tr>
    <td colspan="2">
    	<table cellspacing="0" cellpadding="0">
  		<tr>
    		<td class="paysviganais" width="113" height="113">
				<a href="../index.php" title="L'office du tourisme que je remercie !">
					<img src="../images/paysviganais.jpg" width="113" height="113" border="0"
						 title="Vous allez vous branche sur l'office du Tourisme du Vigan !"/>  
          		</a>			
			</td>
    		<td class="banniere">
				<a href="../index.php" title="Retour à l'index du site Je Crapahute !">
					<img src="../images/banniere.jpg" width="750" height="113" border="0"
						 title="Vous êtes sur le site: Je crapahute !"/>  
          		</a>			
            </td>
   			<td class="etvictor">
				<img src="../images/ETVictor.jpg" width="141" height="113"/>
			</td>
		</tr>
		</table>	
	</td>
</tr>
<!-- ============================================================================================================================ -->
<!--       Menu principal[horizontal]                                                                                             -->
<!-- ============================================================================================================================ -->
<tr>
    <td colspan="2" class="menu">		
		<?php 
			user_error("myPage.php[".$_SESSION[MENU]."]", E_USER_NOTICE) ;
 			if (isset( $_SESSION[MENU] ) && $_SESSION[MENU] )
	 			{	$req = $_SERVER['DOCUMENT_ROOT'] . "/includes/" . $_SESSION[MENU] . ".php" ;    
					if ($debug_myPage)
						user_error("Skeleton[".$req."]  found menu !!!" , E_USER_NOTICE) ;   
					require_once $req ;
				}
 			else
 				{	$req = $_SERVER['DOCUMENT_ROOT'] . "/includes/index.php" ;  
					user_error("Skeleton[SESSION[MENU][".$req."}] doesn't exist => substitution made !!!" , E_USER_WARNING) ;
				} 
			require_once $req ;
		?>
	</td>
</tr>
<!-- ============================================================================================================================ -->
<!--       Ligne de message généré pvia la variable [$kimsg]                                                                      -->
<!-- ============================================================================================================================ -->
<tr>
    <td colspan="2" class="klimsg">
		<table width="100%" cellspacing="0" cellpadding="0">
	  	<tr>
			<td width="20">&nbsp;</td>
    		<td>
				<?php
					if (isset( $_SESSION[SITE] ) )
						{	if (isset( $_SESSION[KLIMSG] ) )
                       			$klimsg = $_SESSION[KLIMSG] ;
							else
                       			{    $klimsg = "Bienvenue sur le site de " . $_SESSION[SITE] ;
						   			 user_error("Substition made for missing variable[KLIMSG]" , E_USER_WARNING) ;
								}
							echo " Je Crapahute a quelque chose à vous dire ==> " . $klimsg ;
						}
					else
						user_error("MYPAGE: la variable $SITE n'existe pas" , E_USER_ERROR) ;
				?>			
			</td>
    		<td>&nbsp;</td>
  		</tr>
		</table>	
	</td>
 </tr>
<!-- ============================================================================================================================ -->
<!--       Page centrale                                                                                                          -->
<!-- ============================================================================================================================ -->
<tr>
    <td>
		<table width="100%" class="areamain">
  		<tr valign="top">
    		<td width="20%" class="areasubmenu">
				<a href="../remarque.php" title=''>
					<img src="../images/working.png" 
		     			title="Soyez tolérant et constructif.... Cliquez cette image pour faire un commentaire, merci !" 
			 			width="125" height="39" border="0" />			
				</a>
				<?php  
 
					if ($this->screen)
                       {   	if ($this->submenu)
								$req = "/submenu/" . $this->submenu . ".php";
							else
                            	{	$req = "/submenu/index.php";
////////                       	  	user_error("Skeleton[.includes/" . $this->menu . ".php ] doesn't exist !!!" , E_USER_WARNING) ;
                            	}
                        	require_once $_SERVER['DOCUMENT_ROOT'] . $req ;
					    }
				?>			
				</td>
   				<td width="80%" class="areamain">
				<?php  
					{	if (isset( $_SESSION["FORM"] ) )
                           	$req ="/doc/do_" . $_SESSION[FORM] . ".php";
						else
                           	{   $req = "/doc/do_index.php";
								$_SESSION[FORM] = "index" ;
							   	user_error("Substition made for missing variable FORM" , E_USER_WARNING) ;
							}
						require_once $_SERVER['DOCUMENT_ROOT'] . $req ;
					}
				?>
		  <td>	
		</tr>
		</table>	
	</td>
<!-- ============================================================================================================================ -->
<!--       Adsense                                                                                                                -->
<!-- ============================================================================================================================ -->
    <td class="adsense">
		<?php 
			require_once $_SERVER['DOCUMENT_ROOT'] .  "/includes/adsense.php";       
		?>
	</td>
</tr>
 
<!-- ============================================================================================================================ -->
<!--       Bottom                                                                                                                 -->
<!-- ============================================================================================================================ -->
<tr>
    <td class="bottom">		
	  	<?php 
			require_once $_SERVER['DOCUMENT_ROOT'] .  "/includes/bottom.php";       
		?>	
	</td>
 
	<td colspan="2">
		<table class="right_cornner" cellspacing="0" cellpadding="0">
  		<tr>
    		<td colspan="2" width="60">&nbsp;</td>
    		<td width="20">
				<a href="#Top" title="Retour au sommet de l'écran">
					<img src="../images/top.gif" title="Retour au sommet de l'écran" width="20" height="20" />				
				</a>							            
			</td>
    		<td colspan="3" width="60">&nbsp;</td>
  		</tr>
		</table>	
	</td>
</tr>
<!-- ============================================================================================================================ -->
</table>
</body>
</html>
<!-- ============================================================================================================================ -->
Y a du boulot n'est ce pas ?
La classe TableDesign est un préréquisite de base pour moi et je m'y attache...

Merci pour ton support !
__________________
Esteban
ETVigan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2011, 12h52   #6
Débutant
 
Avatar de ETVigan
 
Homme Esteban
Conseil - Consultant en systèmes d'information
Inscription : avril 2010
Messages : 632
Détails du profil
Informations personnelles :
Nom : Homme Esteban
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Conseil - Consultant en systèmes d'information
Secteur : Finance

Informations forums :
Inscription : avril 2010
Messages : 632
Points : 122
Points : 122
Envoyer un message via MSN à ETVigan Envoyer un message via Skype™ à ETVigan
Par défaut Class Table

Bonjour,

Concernant le long POST relatif à ce sujet, il y a un petit point que je traite pour l'instant.
Je suis à un poil d'y arriver... à une poil...

Code :
1
2
3
4
5
6
7
8
print($tb->addImage("images/gplv3.png") ) ;   OK

$row4	= array(	
 					$tb->addImage("images\gplv3.png"),
					"Esteban"  ,
					"Victor."
				) ;
Je ne vois pas la différence avec d'autres <IMG ajoutés comme ceci:

Code :
1
2
3
4
5
$row1 	= array(	"<img src=\"images/paysviganais.jpg\" border=0  width=\"113\" height=\"113\" title=\"Le pays Viganais\" />",
					"<img src=\"images/banniere.jpg\" border=0  width=\"750\" height=\"113\" title=\"Les Cimes\" />",
					"<img src=\"images/ETVictor.jpg\" border=0  width=\"141\" height=\"113\" title=\"Moi & Victor\" />"
				) ;
Le addimage me donne:

Code :
1
2
3
4
5
6
7
8
//	$tb->addImage("<img src=\"images/gplv3.png\"/>"),
	function addImage($image)
	{	 //echo $image ;
		 $str =  "<img src=\"$image\">" ;   
		 user_error( $str , E_USER_NOTICE) ;
		 return $str ;
	}
Et dans le log, j'ai:

Code :
1
2
 
PHP Notice:  <img src="images\gplv3.png">
Un p'tit coup de main svp.....
__________________
Esteban
ETVigan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2011, 14h03   #7
Membre Expert
 
Avatar de gwinyam
 
Homme Mathieu ROBIN
Développeur Web
Inscription : mai 2006
Messages : 1 116
Détails du profil
Informations personnelles :
Nom : Homme Mathieu ROBIN
Âge : 25
Localisation : France, Paris (Île de France)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mai 2006
Messages : 1 116
Points : 2 142
Points : 2 142
J'ai pas le temps aujourd'hui, je regarde ça ce soir
__________________
Mon blog techno et son billet hebdomadaire sur l'actualité jQuery. Et mon blog cuisine pour une personne.
Le bouton ne masse pas les pieds, mais ça aide la communauté.
gwinyam est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2011, 14h58   #8
Débutant
 
Avatar de ETVigan
 
Homme Esteban
Conseil - Consultant en systèmes d'information
Inscription : avril 2010
Messages : 632
Détails du profil
Informations personnelles :
Nom : Homme Esteban
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Conseil - Consultant en systèmes d'information
Secteur : Finance

Informations forums :
Inscription : avril 2010
Messages : 632
Points : 122
Points : 122
Envoyer un message via MSN à ETVigan Envoyer un message via Skype™ à ETVigan
Par défaut Class Table

Ok, merci à toi...

LE problème addImage est résolu

Code :
1
2
3
4
5
6
7
 
	function addImage($image)
	{	 //echo $image ;
		 $str =  "<img src=\"$image\" border=0 title=\"NEW\" />" ;   
		 user_error( $str , E_USER_NOTICE) ;
		 return $str ;
	}
Bonnes soirées
__________________
Esteban
ETVigan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2011, 14h25   #9
Débutant
 
Avatar de ETVigan
 
Homme Esteban
Conseil - Consultant en systèmes d'information
Inscription : avril 2010
Messages : 632
Détails du profil
Informations personnelles :
Nom : Homme Esteban
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Conseil - Consultant en systèmes d'information
Secteur : Finance

Informations forums :
Inscription : avril 2010
Messages : 632
Points : 122
Points : 122
Envoyer un message via MSN à ETVigan Envoyer un message via Skype™ à ETVigan
Par défaut Class Table

Mathieu,

J'ai ajouté une méthode pour insérer du code HTML; cela fonctionne car l'interprétation se fait + tard !

Code :
1
2
3
4
5
6
7
	function addHtml($script)
	{	 //echo $image ;
		 $str =  eval("require_once" . $_SERVER['DOCUMENT_ROOT'] . "/HTML/".$script.".html") ;
		 user_error( $str , E_USER_NOTICE) ;
		 return $str ;
	}
Je ne sais pas si c'est possible d'envisager la même chose avec du code PHP

As tu une idée pour les imbrications de table ?

Merci de tes conseils...
__________________
Esteban
ETVigan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2011, 15h10   #10
Membre Expert
 
Avatar de gwinyam
 
Homme Mathieu ROBIN
Développeur Web
Inscription : mai 2006
Messages : 1 116
Détails du profil
Informations personnelles :
Nom : Homme Mathieu ROBIN
Âge : 25
Localisation : France, Paris (Île de France)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mai 2006
Messages : 1 116
Points : 2 142
Points : 2 142
Pour t'aider, je vais juste agrémenter mon exemple précédent :
Code php :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class tableDesign
{
[...]
public function display() {
$tb = "<td".$this->getClassTag("td",$this->width[$col++]).">";
if($cell instanceof tableDesign)
  $tb .= $cell->display();
else
  $tb .= $cell;
$tb .= "</td>\n";
return $tb;
}
[...]
}
Pour moi, ça doit se limiter bêtement à ça.

T'as un parcours ligne par ligne de ton tableau pour afficher des TR puis à chaque cellule, tu manipules une variable $cell qui génère un TD avec un contenu.
Soit ce contenu est une variable classique (string, entier,...), soit elle est une instance d'une table et dans ce cas, tu lui demandes de s'afficher comme si elle était une table normale (ce qu'elle est finalement).
__________________
Mon blog techno et son billet hebdomadaire sur l'actualité jQuery. Et mon blog cuisine pour une personne.
Le bouton ne masse pas les pieds, mais ça aide la communauté.
gwinyam est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/01/2011, 11h15   #11
Débutant
 
Avatar de ETVigan
 
Homme Esteban
Conseil - Consultant en systèmes d'information
Inscription : avril 2010
Messages : 632
Détails du profil
Informations personnelles :
Nom : Homme Esteban
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Conseil - Consultant en systèmes d'information
Secteur : Finance

Informations forums :
Inscription : avril 2010
Messages : 632
Points : 122
Points : 122
Envoyer un message via MSN à ETVigan Envoyer un message via Skype™ à ETVigan
Par défaut Classe Table

Merci Mathieu,

Pas sur de bien comprendre, entre autre quand la balise <table....> sera t'elle générée....
Je teste et te reviendrais + tard, car busy cet aprém
__________________
Esteban
ETVigan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/01/2011, 13h19   #12
Débutant
 
Avatar de ETVigan
 
Homme Esteban
Conseil - Consultant en systèmes d'information
Inscription : avril 2010
Messages : 632
Détails du profil
Informations personnelles :
Nom : Homme Esteban
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Conseil - Consultant en systèmes d'information
Secteur : Finance

Informations forums :
Inscription : avril 2010
Messages : 632
Points : 122
Points : 122
Envoyer un message via MSN à ETVigan Envoyer un message via Skype™ à ETVigan
Par défaut Classe Table

Mathieu,

J'ai fait un 1er test mais comme je n'ai pas intégré tes modifs car ne les pige pas, surtout l'absence de génération de la balise <table....>

Voici mon index.php
Code :
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!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>Test table</title>

<style type="text/css">
#title{
cursor:pointer;
}
.design{
font-weight:bold;
}

.td{
	border:1px solid black;
	text-align:center;
	padding:0px;
	margin: 0px;
}

.table  {
	border-collapse: collapse;
    border:0px;
    margin: 0px;
    padding: 0px;
}

.row  {
	color:red;
}

</style>

</head>

<body>

<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/class/tableDesign.php" ;
//
define("dir_image" , "images" ) ;

$style = array("design" => "design" , "title" => "title" , "td" => "td" , "tr" => "tr" , "table" => "table" ) ;

class Image extends tabledesign
{	private $directory, $name, $width, $height, $title ;

	function __constructor($directory, $name, $width, $height , $title)
	{	$this->directory = $directory ;
		$this->name 	 = $name ;
		$this->width 	 = $width ;
		$this->height 	 = $height ;
		$this->title 	 = $title ;
	}
	
	function __destructor()
	{}
	
	function display()
	{	print( "<img src=\"images/paysviganais.jpg\" border=0  width=\"113\" height=\"113\" title=\"NEW\" />" ) ;
	}
}

$r1c2 = new tableDesign(	"content",	$style , array(5,90,5)	);
$r1c2->addRow(array("A","B","C")) ;


$tb   = new tableDesign(	"content",	$style , array(113,750,141)	);

$row0 	= array(	"A",
					"",
					""
				) ;
$row1 	= array(	"<img src=\"images/paysviganais.jpg\" border=0  width=\"113\" height=\"113\" title=\"Le pays Viganais\" />",
					"<img src=\"images/banniere.jpg\" border=0  width=\"750\" height=\"113\" title=\"Les Cimes\" />",
					"<img src=\"images/ETVictor.jpg\" border=0  width=\"141\" height=\"113\" title=\"Moi & Victor\" />"
				) ;
$row2 	= array(	"<img src=\"images/new.gif\" border=0 title=\"NEW\" />" ,
					"<img src=\"images/del'aigoual.jpg\" border=0 width=\"750\" height=\"113\" title=\"Le mont Aiguoal\" />" ,
					"Row1 Col2" 
                ) ;
				
$row3	= array(	"<img src=\"images/new.gif\" border=0 title=\"new.gif\" />" ,
					$r1c2->display() ,
					"Row3 Col2"
				) ;
//print($tb->addImage("images/gplv3.png") ) ;

$row4	= array(	//"<img src=\"images/gplv3.png\" />",
 					$tb->addImage("images/gplv3.png","title"),
					"Esteban"  ,
					"Victor."
				) ;
				
$tb->addRow($row0) ;
$tb->addRow($row1) ;
$tb->addRow($row2) ;
$tb->addRow($row3) ;
$tb->addRow($row4) ;
				
$tb->display();
?>
</body>
</html>
et ma classe:
Code :
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 
<?php
$style = array("design" => "" , "title" =>	"" , "td" => "" , "tr" => "" , "table" => "" ) ;
 
class tableDesign
{
	private $id_container, $width, $cols, $table_title, $class_design, $class_title, $class_td, $class_tr, $class_table ;
 
	function __construct(	$id_container="", 		// If table sould be contained in <div id="conainer"
							$id_style		,
							$width
						)
	{	$this->id_container = $id_container;
		$this->cols			= count($width) ;
		$this->width        = $width ;
 
		foreach ($id_style as $key => $val)
		{	switch($key)
			{	case "design": 	$this->class_design = $val ;
								break ;
				case "title" :	$this->class_title  = $val ;
								break ;
				case "td"	 :	$this->class_td     = $val ;
								break ;
				case "tr"	 :  $this->class_tr     = $val ;
								break ;
				case "table" :  $this->class_table  = $val ;
								break ;
				default  	 :  user_error("Bad value for style" , E_USER_ERROR) ;
			}
		}
	}
 
	function getClassTag($node,$width=0)
	{	switch($node)
		{	case "design":	return ($this->class_design !="" ?" class=\"".$this->class_design."\"" : "") ;
							break;
 
			case "title":	return ($this->class_title != "" ? " class=\"".$this->class_title."\"" : "") ;
							break;
 
			case "td":		return ($this->class_td    != "" ? " class=\"".$this->class_td."\" width=\"".$width."\"" : "") ;
							break;
 
			case "tr":		return ($this->class_tr    != "" ? " class=\"".$this->class_tr."\"" : "") ;
							break;
 
			case "table":	return ($this->class_table != "" ? " class=\"".$this->class_table."\"" : "" ) ;
							break;
 
			default: 		return ""; 
							break;
		}
	}
 
	function addRow($rows)
	{	if ($this->cols == count($rows) )
			$this->data[] = $rows ;
		else
			user_error("Invalid Column count in AddRow function" , E_USER_ERROR) ;
	}
 
	function addImage($image,$title)
	{	 $str =  "<img src=\"$image\" border=0 title=\"$title\" />" ;   
		 user_error( $str , E_USER_NOTICE) ;
		 return $str ;
	}
 
	function addHtml($script)
	{	 $str =  eval("require_once" . $_SERVER['DOCUMENT_ROOT'] . "/HTML/".$script.".html") ;
//		 user_error( $str , E_USER_NOTICE) ;
		 return $str ;
	}
 
	function display()
	{	$tb = "";
//
//		Print HTML code
//		===============
		if ($this->id_container != "")
			$tb .= "<div id=\"".$this->id_container."\">\n";
 
		$tb .= "<table".$this->getClassTag("table").">\n";
//
		foreach ($this->data as $row => $data)
		{	$tb .= "<tr".$this->getClassTag("tr").">\n";
			$col = 0 ;
			foreach($data as $key => $cell)
			{ 	if (empty($cell))
			     	$cell = "&nbsp;" ;
//				-------------------------------------------------------------------------------
//				$tb .= "<td".$this->getClassTag("td",$this->width[$col++]).">".$cell."</td>\n";
//				Dixit le forum des pros ! 3/1/2011
//				-------------------------------------------------------------------------------
				$tb .= "<td".$this->getClassTag("td",$this->width[$col++]).">";
				if($cell instanceof tableDesign)
				  $tb .= $cell->display();
				else
				  $tb .= $cell;
				$tb .= "</td>\n";
 
 
			}
			$tb .= "</tr>\n";
		}
		$tb .= "</table>\n";
 
		if ($this->id_container != "")
			$tb .= "</div>\n";
//
//		End of printing
//		===============		
		echo $tb .= "\n";
	}
/*	
	public function display() {
		$tb = "<td".$this->getClassTag("td",$this->width[$col++]).">";
		if($cell instanceof tableDesign)
		  $tb .= $cell->display();
		else
		  $tb .= $cell;
		$tb .= "</td>\n";
		return $tb;
	}
*/
}
?>
ton display() est n commentaire en bas...

Les 2 tables sont =générées mais pas imbriquées... voir JPG en pièce attachée

Affaire à suivre comme dirait l'autre....

Merci pour ton aide
Images attachées
Type de fichier : jpg tabledesign.jpg (33,8 Ko, 3 affichages)
__________________
Esteban
ETVigan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/01/2011, 14h17   #13
Membre Expert
 
Avatar de gwinyam
 
Homme Mathieu ROBIN
Développeur Web
Inscription : mai 2006
Messages : 1 116
Détails du profil
Informations personnelles :
Nom : Homme Mathieu ROBIN
Âge : 25
Localisation : France, Paris (Île de France)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mai 2006
Messages : 1 116
Points : 2 142
Points : 2 142
Avec la classe complète, je viens de voir où est le souci.

En fait, à la fin de ton display, tu ne devrais pas faire un echo. Juste un return de $tb.

Comme ça dans ton programme principal, quand tu appelles display(), tu mets un echo devant et là ça sera correctement imbriqué.

Code :
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
$style = array("design" => "" , "title" =>	"" , "td" => "" , "tr" => "" , "table" => "" ) ;
 
class tableDesign
{
	private $id_container, $width, $cols, $table_title, $class_design, $class_title, $class_td, $class_tr, $class_table ;
 
	function __construct(	$id_container="", 		// If table sould be contained in <div id="conainer"
							$id_style		,
							$width
						)
	{	$this->id_container = $id_container;
		$this->cols			= count($width) ;
		$this->width        = $width ;
 
		foreach ($id_style as $key => $val)
		{	switch($key)
			{	case "design": 	$this->class_design = $val ;
								break ;
				case "title" :	$this->class_title  = $val ;
								break ;
				case "td"	 :	$this->class_td     = $val ;
								break ;
				case "tr"	 :  $this->class_tr     = $val ;
								break ;
				case "table" :  $this->class_table  = $val ;
								break ;
				default  	 :  user_error("Bad value for style" , E_USER_ERROR) ;
			}
		}
	}
 
	function getClassTag($node,$width=0)
	{	switch($node)
		{	case "design":	return ($this->class_design !="" ?" class=\"".$this->class_design."\"" : "") ;
							break;
 
			case "title":	return ($this->class_title != "" ? " class=\"".$this->class_title."\"" : "") ;
							break;
 
			case "td":		return ($this->class_td    != "" ? " class=\"".$this->class_td."\" width=\"".$width."\"" : "") ;
							break;
 
			case "tr":		return ($this->class_tr    != "" ? " class=\"".$this->class_tr."\"" : "") ;
							break;
 
			case "table":	return ($this->class_table != "" ? " class=\"".$this->class_table."\"" : "" ) ;
							break;
 
			default: 		return ""; 
							break;
		}
	}
 
	function addRow($rows)
	{	if ($this->cols == count($rows) )
			$this->data[] = $rows ;
		else
			user_error("Invalid Column count in AddRow function" , E_USER_ERROR) ;
	}
 
	function addImage($image,$title)
	{	 $str =  "<img src=\"$image\" border=0 title=\"$title\" />" ;   
		 user_error( $str , E_USER_NOTICE) ;
		 return $str ;
	}
 
	function addHtml($script)
	{	 $str =  eval("require_once" . $_SERVER['DOCUMENT_ROOT'] . "/HTML/".$script.".html") ;
//		 user_error( $str , E_USER_NOTICE) ;
		 return $str ;
	}
 
	function display()
	{	$tb = "";
//
//		Print HTML code
//		===============
		if ($this->id_container != "")
			$tb .= "<div id=\"".$this->id_container."\">\n";
 
		$tb .= "<table".$this->getClassTag("table").">\n";
//
		foreach ($this->data as $row => $data)
		{	$tb .= "<tr".$this->getClassTag("tr").">\n";
			$col = 0 ;
			foreach($data as $key => $cell)
			{ 	if (empty($cell))
			     	$cell = "&nbsp;" ;
//				-------------------------------------------------------------------------------
//				$tb .= "<td".$this->getClassTag("td",$this->width[$col++]).">".$cell."</td>\n";
//				Dixit le forum des pros ! 3/1/2011
//				-------------------------------------------------------------------------------
				$tb .= "<td".$this->getClassTag("td",$this->width[$col++]).">";
				if($cell instanceof tableDesign)
				  $tb .= $cell->display();
				else
				  $tb .= $cell;
				$tb .= "</td>\n";
 
 
			}
			$tb .= "</tr>\n";
		}
		$tb .= "</table>\n";
 
		if ($this->id_container != "")
			$tb .= "</div>\n";
//
//		End of printing
//		===============
/*
 * ICI
 */		
		return $tb .= "\n";
	}
/*	
	public function display() {
		$tb = "<td".$this->getClassTag("td",$this->width[$col++]).">";
		if($cell instanceof tableDesign)
		  $tb .= $cell->display();
		else
		  $tb .= $cell;
		$tb .= "</td>\n";
		return $tb;
	}
*/
}
?>
L'astuce est que, là, display() va commencer à générer le code HTML de ton premier tableau et quand il va rencontrer une valeur ($cell) qui est en fait elle aussi une instance de tableDesign, il va générer son code HTML et le retourner.
Comme ça il est concaténé au code du premier tableau puis la fin du tableau sera rajouté.

Et là tadam, tes tableaux sont générés et imbriqués. Récursivement, si tu rajoutes d'autres tableaux, que ce soit au premier niveau, au deuxième ou même énième niveau, ils seront générés automatiquement et imbriqués à leur place.

A tester et confirmer.
__________________
Mon blog techno et son billet hebdomadaire sur l'actualité jQuery. Et mon blog cuisine pour une personne.
Le bouton ne masse pas les pieds, mais ça aide la communauté.
gwinyam est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/01/2011, 15h17   #14
Débutant
 
Avatar de ETVigan
 
Homme Esteban
Conseil - Consultant en systèmes d'information
Inscription : avril 2010
Messages : 632
Détails du profil
Informations personnelles :
Nom : Homme Esteban
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Conseil - Consultant en systèmes d'information
Secteur : Finance

Informations forums :
Inscription : avril 2010
Messages : 632
Points : 122
Points : 122
Envoyer un message via MSN à ETVigan Envoyer un message via Skype™ à ETVigan
Par défaut Classe Table

Mathieu,

Donc comme ceci:

Code :
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
49
50
51
52
53
	function display()
	{	$tb = "";
//
//		Print HTML code
//		===============
		if ($this->id_container != "")
			$tb .= "<div id=\"".$this->id_container."\">\n";
		
		$tb .= "<table".$this->getClassTag("table").">\n";
//
		foreach ($this->data as $row => $data)
		{	$tb .= "<tr".$this->getClassTag("tr").">\n";
			$col = 0 ;
			foreach($data as $key => $cell)
			{ 	if (empty($cell))
			     	$cell = "&nbsp;" ;
//				-------------------------------------------------------------------------------
//				$tb .= "<td".$this->getClassTag("td",$this->width[$col++]).">".$cell."</td>\n";
//				Dixit le forum des pros ! 3/1/2011
//				-------------------------------------------------------------------------------
				$tb .= "<td".$this->getClassTag("td",$this->width[$col++]).">";
				if($cell instanceof tableDesign)
				  $tb .= $cell->display();
				else
				  $tb .= $cell;
				$tb .= "</td>\n";


			}
			$tb .= "</tr>\n";
		}
		$tb .= "</table>\n";
		
		if ($this->id_container != "")
			$tb .= "</div>\n";
//
//		End of printing
//		===============		
//		echo $tb .= "\n";
		return $tb .= "\n";	
        }
/*	
	public function display() {
		$tb = "<td".$this->getClassTag("td",$this->width[$col++]).">";
		if($cell instanceof tableDesign)
		  $tb .= $cell->display();
		else
		  $tb .= $cell;
		$tb .= "</td>\n";
		return $tb;
	}
*/
Et bien, je n'ai plus rien ET RIEN aussi dans le, dans le log.php .....

Merci mais je vais arrêter un peu car mes neurones comateuses se rappellent à l'ordre !
__________________
Esteban
ETVigan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/01/2011, 15h00   #15
Débutant
 
Avatar de ETVigan
 
Homme Esteban
Conseil - Consultant en systèmes d'information
Inscription : avril 2010
Messages : 632
Détails du profil
Informations personnelles :
Nom : Homme Esteban
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Conseil - Consultant en systèmes d'information
Secteur : Finance

Informations forums :
Inscription : avril 2010
Messages : 632
Points : 122
Points : 122
Envoyer un message via MSN à ETVigan Envoyer un message via Skype™ à ETVigan
Par défaut Classe Table

Du neuf Mathieu ?
__________________
Esteban
ETVigan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/01/2011, 16h19   #16
Membre Expert
 
Avatar de gwinyam
 
Homme Mathieu ROBIN
Développeur Web
Inscription : mai 2006
Messages : 1 116
Détails du profil
Informations personnelles :
Nom : Homme Mathieu ROBIN
Âge : 25
Localisation : France, Paris (Île de France)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mai 2006
Messages : 1 116
Points : 2 142
Points : 2 142
Peut-être ce soir si j'ai le temps, sinon demain soir. Désolé, je suis over-booké et mon cerveau est en train de faire un bon vieux fail-overflow.
__________________
Mon blog techno et son billet hebdomadaire sur l'actualité jQuery. Et mon blog cuisine pour une personne.
Le bouton ne masse pas les pieds, mais ça aide la communauté.
gwinyam est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/01/2011, 11h55   #17
Débutant
 
Avatar de ETVigan
 
Homme Esteban
Conseil - Consultant en systèmes d'information
Inscription : avril 2010
Messages : 632
Détails du profil
Informations personnelles :
Nom : Homme Esteban
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Conseil - Consultant en systèmes d'information
Secteur : Finance

Informations forums :
Inscription : avril 2010
Messages : 632
Points : 122
Points : 122
Envoyer un message via MSN à ETVigan Envoyer un message via Skype™ à ETVigan
Par défaut Classe Table

Du neuf ? Mathieu, ne t'inquiète je suis aussi overbooké ....
__________________
Esteban
ETVigan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/01/2011, 14h32   #18
Membre Expert
 
Avatar de gwinyam
 
Homme Mathieu ROBIN
Développeur Web
Inscription : mai 2006
Messages : 1 116
Détails du profil
Informations personnelles :
Nom : Homme Mathieu ROBIN
Âge : 25
Localisation : France, Paris (Île de France)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mai 2006
Messages : 1 116
Points : 2 142
Points : 2 142
Je viens de prendre le temps, j'ai bien rigolé quand j'ai compris. On n'a pas été futé sur le coup...

Le coup du return de tb dans display, c'est très bien, mais encore faut il l'afficher dans index.php

Normalement, ligne 102 t'as ça:
Mets ça à la place
ça marche très bien chez moi

Je pensais qu'on avait déjà évoqué ce truc là mais visiblement j'ai oublié de te le dire.
__________________
Mon blog techno et son billet hebdomadaire sur l'actualité jQuery. Et mon blog cuisine pour une personne.
Le bouton ne masse pas les pieds, mais ça aide la communauté.
gwinyam est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/01/2011, 14h57   #19
Débutant
 
Avatar de ETVigan
 
Homme Esteban
Conseil - Consultant en systèmes d'information
Inscription : avril 2010
Messages : 632
Détails du profil
Informations personnelles :
Nom : Homme Esteban
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Conseil - Consultant en systèmes d'information
Secteur : Finance

Informations forums :
Inscription : avril 2010
Messages : 632
Points : 122
Points : 122
Envoyer un message via MSN à ETVigan Envoyer un message via Skype™ à ETVigan
Par défaut Classe Table

Effectivement, on n'a pas été futé sur ce prob là !!!!!!
Cela fonctionne aussi sauf que la 2ième table n'est pas la bonne place BUT THIS IS Peanuts.....

Merci encore... moi aussi j'aurai du voir....
================================
Code :
1
2
3
4
5
6
7
8
9
10
11
12
Mais comment ferais-tu pour le row-col/span ?
Il me semblait que c'était clair mais maintenant que je m'y remets.....

A,B,C doivent être rowspanned mais cela me paraissait + simple
G,H,I aussi

Par contre
A,D,G & C,F,I doivent être colspanned

Je détecte déjà que ABC doivent être COLSPANNED

Le tout devant faire un cadre autour de la cellule E
Merci Mathieu....
Fichiers attachés
Type de fichier : php tableDesign.php (3,7 Ko, 0 affichages)
Type de fichier : php index.php (2,7 Ko, 0 affichages)
__________________
Esteban
ETVigan est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 14h41.


 
 
 
 
Partenaires

Hébergement Web