Afficher une fonction

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Afficher une fonction

par HD » 10 sept. 2005, 02:55

t'es tres sympa truc mais mr l'invité doit aussi faire des efforts pour comprendre son code et pouvoir ainsi resoudre ces petits bemoles lui meme

par Truc » 10 sept. 2005, 02:09

euh .. oui on va y arriver :roll:
if($passage == 1)
        {
            echo "<tr>";         
            echo "<td align=\"right\" nowrap><b>(Mi-temps : </b>";
        }
voila ce coup ci ca doit etre la bonne , par contre je verai ça a mon réveil :wink: (en espérant que c'est la bonne)

par Invité » 10 sept. 2005, 02:00

Ben maintenant c'est la fin de la parenthèse qui est montée aussi. On va y arriver :wink:

Image

par Truc » 10 sept. 2005, 01:29

euh .. oui en effet ca fait desordre :shock:
if($passage == 1)
        {
            echo "<tr>";         
            echo "<td align=\"right\" nowrap><b>(Mi-temps : </b></td>";
        }
       
      for ($i=1;$i <= $this->size(); $i++) {
         $value = $this->fetchRowValueTeam($data, $i);
         
         if ($display == 1)
            {
                echo "$value";
                if($passage == 1)
                    echo ' - ';
            }
         else
            echo "<input type=\"text\" name=\"team" . $id . "_period[$i]\" value=\"$value\" size=\"1\">";
         
      }
      if($passage == 2)
        {
            echo ")</td>";
            echo "</tr>";
        }
   }
comme ca, erreur de <td>il me semble (pas facile de faire ca a l'oeil nu :? )

par Invité » 10 sept. 2005, 01:22

Merci pour ta rapidité.

Petit problème, le score se fait la malle en allant tout en haut confèr l'image

Image

par Truc » 10 sept. 2005, 01:12

Content que ca marche :lol:

essai comme ca pour réduire les espaces:
if($passage == 1)
        {
            echo "<tr>";         
            echo "<td align=\"right\" nowrap><b>(Mi-temps : </b></td>";
        }
       
      for ($i=1;$i <= $this->size(); $i++) {
         $value = $this->fetchRowValueTeam($data, $i);
         
         if ($display == 1)
            {
                echo "$value";
                if($passage == 1)
                    echo ' - ';
            }
         else
            echo "<input type=\"text\" name=\"team" . $id . "_period[$i]\" value=\"$value\" size=\"1\">";
         
      }
      if($passage == 2)
        {
            echo "<td align=\"right\" nowrap>)</td>";
            echo "</tr>";
        }
   }

par Invité » 10 sept. 2005, 01:01

Salut, j'ai pas testé mais en remplaçant les 3 dernières fonctions comme ceci, peut etre que ca marchera ( avec un peu de chance [-o< )
C'est pas de la chance, c'est du talent. Ca marcheeeeeeeeeee :lol: 8) :D :wink: . Merci d'avoir pris le temps d'essayer. Je suis vachement content.

J'ai un peu modifié le code mais ça donne pas tout à fait ce que je veux .

Là ça donne ça sur l'écran (voir image). Il y a trop d'espace :

Image

Comment faire pour que cela affiche ça : (Mi temps : 2-0)

Code : Tout sélectionner

function printTeamSummary($team, $data, $id, $display=1,$passage) { if($passage == 1) { echo "<tr>"; echo "<td align="right" nowrap><b>(Mi-temps : </b></td>"; } for ($i=1;$i <= $this->size(); $i++) { $value = $this->fetchRowValueTeam($data, $i); echo "<td align="center">"; if ($display == 1) { echo "$value"; if($passage == 1) echo ''; } else echo "<input type="text" name="team" . $id . "_period[$i]" value="$value" size="1">"; echo "</td>"; } if($passage == 2) { echo "<td align="right" nowrap>)</td>"; echo "</tr>"; } } function printTeam1Summary($display) { $this->printTeamSummary(getTeamName($this->tid1), $this->data_team1, "1", $display,1); } function printTeam2Summary($display) { $this->printTeamSummary(getTeamName($this->tid2), $this->data_team2, "2", $display,2); }
Vraiment merci pour ton aide

par Truc » 09 sept. 2005, 14:18

Salut, j'ai pas testé mais en remplaçant les 3 dernières fonctions comme ceci, peut etre que ca marchera ( avec un peu de chance [-o< )
function printTeamSummary($team, $data, $id, $display=1,$passage) 
{
      
	  if($passage == 1)
		{
			echo "<tr>";		
			echo "<td align=\"right\" nowrap><b>" . $team . ":</b>&nbsp;</td>";
		}
	   
      for ($i=1;$i <= $this->size(); $i++) {
         $value = $this->fetchRowValueTeam($data, $i);
         echo "<td align=\"center\">";
         if ($display == 1)
            {
				echo "$value";
				if($passage == 1)
					echo ' : ';
			}
         else
            echo "<input type=\"text\" name=\"team" . $id . "_period[$i]\" value=\"$value\" size=\"2\">";
         echo "</td>";
      }
      if($passage == 2)
		{
			echo "<td align=\"right\" nowrap><b>" . $team . ":</b>&nbsp;</td>";
			echo "</tr>";
		}
   }

   function printTeam1Summary($display) {
      $this->printTeamSummary(getTeamName($this->tid1), $this->data_team1, "1", $display,1);
   }

   function printTeam2Summary($display) {
      $this->printTeamSummary(getTeamName($this->tid2), $this->data_team2, "2", $display,2);
   } 
sinon j'en sais pas plus, en tout cas je ne vois pas d'autre endroits ou ça "affiche".

par Cyrano » 09 sept. 2005, 14:01

Difficile sans avoir l'ensemble des classes. Tu as téléchargé ça où ? À priori, il y a soit une méthode à ré-écrire soit une surcharge à concevoir.

par Invité » 09 sept. 2005, 12:10

Le code n'est pas de moi.

Je pense que pour modifier l'apparence ce qui nous interesse est :

$game->printTeam1Summary ($display) ; $game->printTeam2Summary($display);

Ce code affiche comme ça :

Paris : 2
Metz : 0

Dans classes.php il y a ça :

function printTeam1Summary($display) {
$this->printTeamSummary(getTeamName($this->tid1), $this->data_team1, "1", $display);
}

function printTeam2Summary($display) {
$this->printTeamSummary(getTeamName($this->tid2), $this->data_team2, "2", $display);
}

Je voudrais que cela s'affiche comme ça :

Mi-temps : 2-0

Qui peut me sauver la mise svp

par Cyrano » 07 sept. 2005, 09:36

J'adore le code pas commenté du tout :? : C'est toi qui as pondu ces classes ? Je présume que non, tu l'as téléchargé avec un kit complet : tu as un lien vers le site ?

par Invité » 07 sept. 2005, 09:11

Ca doit être par là alors :wink:
/*
 * Generic class to create dynamicTables
 */

class dynamicTable {
   var $result;
   var $setup;
   var $size;
   var $index;
   var $pos;
   var $calcStart;
   var $rows;
   var $start;

   /*
    * Return the ID of the setup row
    */

   function id() {
      return $this->setup['id'];
   }

   /*
    * The number of headers
    */

   function size() {
      return $this->size;
   }

   function ok() {
      return ($this->rows > 0);
   }

   /*
    * Return the next heading
    */

   function headings($i=-1) {

      if ($i == -1) {
         if ($this->setup[$this->index] != "") {
            $this->index++;
            return ($this->setup[$this->index-1]);
         }
         else
            return false;
      }

      return ($this->setup[$i+2]);
   }

   /*
    * See if we have a calculated field
    */

   function ifCalc($i) {
      return ($this->setup[$i+$this->calcStart]!=""); 
   }


   /*
    * Return the calculated field 
    */

   function calc($i) {
      return ($this->setup[$i+$this->calcStart - 1]);
   }

   /* 
    * Return the postion number of the standing
    */

   function position($i) {
      if ($this->setup[$i+$this->calcStart]=="pos") {
         $origpos = $this->pos;
         $this->pos++;
         return $origpos;
      }
      return "";
   }

   /*
    * Get a row of data for this dynamic table
    */

   function fetchRow(&$data_result, &$data) {
      global $db;

      $data = $db->sql_fetchrow($data_result);

      if (empty($data)) {
         return false;
      }

      return (true);
   }

   /*
    * Return the next data value from a row of data
    */

   function fetchRowValue(&$data_index, &$data, $start, $i=0) {
      $index = $data_index;
      $index2 = $index + 1;

      if ($i == 0) {
         if ($data[$index] != "") {
            $data_index = $index2;
            return ($data[$index]);
         }
      }
      return ($data[$i + $start]);
   }
}

/*
 * Stanndings tables
 */

class Standings extends dynamicTable {
   var $data;
   var $data_index;
   var $data_result;

   function Standings($lid) {
      global $prefix, $db;

      $this->result = $db->sql_query("select * from " . $prefix . "_league_standings_setup where lid = $lid");
      $this->setup = $db->sql_fetchrow($this->result);
      $this->rows = $db->sql_numrows($this->result);

      $c=0;
      for ($i=2; $i < 17; $i++) {
         if ($this->setup[$i] != "")
            $c++;
         else
            break;
      }
      $this->size = $c;
      $this->start = 2;
      $this->index = 2;
      $this->pos = 1;
      $this->calcStart=17;
   }

   function size() {
      return ($this->size);
   }

   function select($did, $sid, $limit=0, $tid=0) {
      global $prefix, $db;

      if ($did != 0)
         $select_did = " and " . $prefix . "_league_team_seasons.did = $did ";
      else
         $select_did = "";

      $select = "select " . $prefix . "_league_teams.id as tid, " . $prefix . "_league_standings.id as stdid,";
      $j=1;
      for ($i=$this->calcStart; $i < $this->size+$this->calcStart; $i++) {
         if ($this->setup[$i] != "") {
            if ($this->setup[$i] == "pos")
               $select .= "1 as std$j,";
            else
               $select .= eregi_replace("col","std",$this->setup[$i]) . " as std$j,";
         }
         else {
            $select .= "std$j,";
         }
         $j++;
      }
      $select = substr($select, 0, strlen($select)-1);

      $select .= " from " . $prefix . "_league_team_seasons, " . $prefix . "_league_teams," . $prefix . "_league_standings where " . $prefix . "_league_teams.id = " . $prefix . "_league_standings.tid and " . $prefix . "_league_standings.sid = $sid and " . $prefix . "_league_team_seasons.sid = " . $prefix . "_league_standings.sid and " . $prefix . "_league_teams.id = " . $prefix . "_league_team_seasons.tid $select_did";

      if ($tid != 0)
         $select .= "and " . $prefix . "_league_teams.id = $tid ";

      $by = "";
      $order = "";
      if ($this->setup['sort1'] > 0) {
         $order = "order by ";
         $by .= "std" . $this->setup['sort1'] . " desc,";
      }
      if ($this->setup['sort2'] > 0) {
         $order = "order by ";
         $by .= "std" . $this->setup['sort2'] . " desc,";
      }
      if ($this->setup['sort3'] > 0) {
         $order = "order by ";
         $by .= "std" . $this->setup['sort3'] . " desc,";
      }
      if (strlen($order) > 0) {
         $by = substr($by, 0, strlen($by)-1);
         $select .= "$order $by";
      }
      if ($limit > 0)
         $select .= " limit $limit";

//echo "$select<br><br>";
      $this->data_result = $db->sql_query($select);
   }

   function fetchSetupSort() {

      $row = array();
      $row[0] = $this->setup['sort1'];
      $row[1] = $this->setup['sort2'];
      $row[2] = $this->setup['sort3'];

      return ($row);
   }

   function fetchSetupGame() {

      $row = array();
      $row[0] = $this->setup['W'];
      $row[1] = $this->setup['T'];
      $row[2] = $this->setup['L'];
      $row[3] = $this->setup['PF'];
      $row[4] = $this->setup['PA'];

      return ($row);
   }

   function fetchRowStdid() {
      return ($this->data['stdid']);
   }

   function fetchRow() {
      $ret = dynamicTable::fetchRow($this->data_result, $this->data);
      if ($ret)
         $this->data_index = 2;
      else
         $this->data_index = 0;
      
      return $ret;
   }

   function fetchRowValue($i=0) {
      return dynamicTable::fetchRowValue($this->data_index, $this->data, 
                                  $this->start, $i);
   }

   function tid() {
      return $this->data['tid'];
   }
}

/*
 * Game Summary table
 */

class Games extends dynamicTable {
   var $data_index;
   var $tid1;
   var $tid2;
   var $data_team1_result;
   var $data_team2_result;
   var $data_team1;
   var $data_team2;

   function Games($lid) {
   global $prefix, $db;

      $this->result = $db->sql_query("select * from " . $prefix . "_league_schedule_summary_setup where lid = $lid");
      $this->setup = $db->sql_fetchrow($this->result);
      $this->rows = $db->sql_numrows($this->result);

      $c=0;
      for ($i=2;$i < 13; $i++) {
         if ($this->setup[$i] != "")
            $c++;
      }

      $this->size = $c;
      $this->index = 2;
      $this->start = 2;
   }

   function select($schid, $tid) {
      global $prefix, $db;

      $result = $db->sql_query("select * from " . $prefix . "_league_schedule_summary where schid = $schid and tid = $tid");
      return ($result);
   }

   function fetchRow(&$result, &$data) {
      $ret = dynamicTable::fetchRow($result, $data);
      if ($ret)
         $this->data_index = 3;
      else
         $this->data_index = 0;
      
      return $ret;
   }

   function setTid1($tid) {
      $this->tid1 = $tid;
   }

   function setTid2($tid) {
      $this->tid2 = $tid;
   }

   function fetchRowValueTeam(&$data, $i) {
      return dynamicTable::fetchRowValue($this->data_index, $data, 
                                  $this->start, $i, 1);
   }

   function summaryTeam1($schid) {
      $this->data_team1_result = $this->select($schid, $this->tid1);
      $this->fetchRow($this->data_team1_result, $this->data_team1);
   }

   function summaryTeam2($schid) {
      $this->data_team2_result = $this->select($schid, $this->tid2);
      $this->fetchRow($this->data_team2_result, $this->data_team2);
   }

   function summaryTeamOK($team_data) {
      for($i=1; $i <= $this->size+1; $i++) {
         $val = $this->fetchRowValueTeam($team_data, $i);
         if ($val != "")
            return 1;
      }

      return 0;
   }

   function summaryTeam1OK() {
      return ($this->summaryTeamOK($this->data_team1));
   }

   function summaryTeam2OK() {
      return ($this->summaryTeamOK($this->data_team1));
   }

   function printTeamSummary($team, $data, $id, $display=1) {
      echo "<tr>";
      echo "<td align=\"right\" nowrap><b>" . $team . ":</b>&nbsp;</td>";
      for ($i=1;$i <= $this->size(); $i++) {
         $value = $this->fetchRowValueTeam($data, $i);
         echo "<td align=\"center\">";
         if ($display == 1)
            echo "$value";
         else
            echo "<input type=\"text\" name=\"team" . $id . "_period[$i]\" value=\"$value\" size=\"2\">";
         echo "</td>";
      }
      echo "</tr>";
   }

   function printTeam1Summary($display) {
      $this->printTeamSummary(getTeamName($this->tid1), $this->data_team1, "1", $display);
   }

   function printTeam2Summary($display) {
      $this->printTeamSummary(getTeamName($this->tid2), $this->data_team2, "2", $display);
   }
}

par Cyrano » 07 sept. 2005, 08:44

La classe Games est incomplète... il en manque à priori un bout, vérifie et reviens confirmer ou non.

par Invité » 06 sept. 2005, 22:46

Quelqu'un peut venir à mon secours svp ?

par Invité » 05 sept. 2005, 13:23

Oui je peux le faire :lol: :lol: :wink:

Code : Tout sélectionner

/* * Generic class to create dynamicTables */ class dynamicTable { var $result; var $setup; var $size; var $index; var $pos; var $calcStart; var $rows; var $start; /* * Return the ID of the setup row */ function id() { return $this->setup['id']; } /* * The number of headers */ function size() { return $this->size; } function ok() { return ($this->rows > 0); } /* * Return the next heading */ function headings($i=-1) { if ($i == -1) { if ($this->setup[$this->index] != "") { $this->index++; return ($this->setup[$this->index-1]); } else return false; } return ($this->setup[$i+2]); } /* * See if we have a calculated field */ function ifCalc($i) { return ($this->setup[$i+$this->calcStart]!=""); } /* * Return the calculated field */ function calc($i) { return ($this->setup[$i+$this->calcStart - 1]); } /* * Return the postion number of the standing */ function position($i) { if ($this->setup[$i+$this->calcStart]=="pos") { $origpos = $this->pos; $this->pos++; return $origpos; } return ""; } /* * Get a row of data for this dynamic table */ function fetchRow(&$data_result, &$data) { global $db; $data = $db->sql_fetchrow($data_result); if (empty($data)) { return false; } return (true); } /* * Return the next data value from a row of data */ function fetchRowValue(&$data_index, &$data, $start, $i=0) { $index = $data_index; $index2 = $index + 1; if ($i == 0) { if ($data[$index] != "") { $data_index = $index2; return ($data[$index]); } } return ($data[$i + $start]); } }