par
sebe de kain » 29 févr. 2008, 01:07
Voilà avec vos aides et conseilles combinés, j'obtiens un résultat acceptable:
// Fichier php
function part() {
global $database, $mosConfig_lang;
$bout = mosGetParam( $_REQUEST, 'coureur', '' );
if ($bout == '') {
$bout = mosGetParam( $_REQUEST, 'bout', '' );
}
/////////// Item et lien(s) ///////////
$link = lien ($task = 'fiche_participant');
$link .= '&id=';
if ($bout != '') {
$query = "SELECT id, nom, prenom, naissance"
. "\n FROM #__classement_participant"
. "\n WHERE nom LIKE '" . $bout . "%'"
. "\n ORDER BY nom ASC"
;
$database->setQuery( $query );
$runnerlist = $database->loadObjectList();
foreach($runnerlist as $key => $runner){
$runnerlist[$key]->nom = '<a href="' . $link . $runner->id . '">' . $runner->nom . '</a>';
$runnerlist[$key]->prenom = '<a href="' . $link . $runner->id . '">' . $runner->prenom . '</a>';
if ($mosConfig_lang == 'french') {
setlocale(LC_TIME, "fr");
$runnerlist[$key]->naissance = strftime("%d %B %Y",strtotime($runner->naissance));
}
}
}//fin du if
classement_html::runnerlist($mosConfig_lang, $runnerlist, $link);
}
// Fichier HTML
function runnerlist($lang, $runnerlist, $link) {
if ($runnerlist != '') {
echo '<br/><br/>';
$restriction = array('id');
$entete = array(
nom=>constant('_PREFIXnom'),
prenom=>constant('_PREFIXprenom'),
naissance=>constant('_PREFIXnaissance'));
classement_html::tableau($runnerlist, $entete, $restriction);
}// fin du if
}// fin fonction coureur
// Fonction création d'un tableau
function tableau($list, $entete, $restriction){
echo '<table width="100%" border="0" cellspacing="10" cellpadding="0">'."\n";
//l'entete du tableau
echo '<tr>';
foreach($entete as $libelle){
echo '<td>' . $libelle . '</td>';
}
echo '</tr>';
//les donnees
//les lignes
while(list(, $objet) = each($list)){
echo '<tr>';
//les colonnes à partir de l'entête
foreach($objet as $name => $value) {
if(!in_array($name, $restriction)) {
echo '<td>' . $value . '</td>';
}
}
echo '</tr>';
}
echo '</table>';
}
Puis-je encore améliorer mon résultat ?
Merci
Voilà avec vos aides et conseilles combinés, j'obtiens un résultat acceptable:
[php]// Fichier php
function part() {
global $database, $mosConfig_lang;
$bout = mosGetParam( $_REQUEST, 'coureur', '' );
if ($bout == '') {
$bout = mosGetParam( $_REQUEST, 'bout', '' );
}
/////////// Item et lien(s) ///////////
$link = lien ($task = 'fiche_participant');
$link .= '&id=';
if ($bout != '') {
$query = "SELECT id, nom, prenom, naissance"
. "\n FROM #__classement_participant"
. "\n WHERE nom LIKE '" . $bout . "%'"
. "\n ORDER BY nom ASC"
;
$database->setQuery( $query );
$runnerlist = $database->loadObjectList();
foreach($runnerlist as $key => $runner){
$runnerlist[$key]->nom = '<a href="' . $link . $runner->id . '">' . $runner->nom . '</a>';
$runnerlist[$key]->prenom = '<a href="' . $link . $runner->id . '">' . $runner->prenom . '</a>';
if ($mosConfig_lang == 'french') {
setlocale(LC_TIME, "fr");
$runnerlist[$key]->naissance = strftime("%d %B %Y",strtotime($runner->naissance));
}
}
}//fin du if
classement_html::runnerlist($mosConfig_lang, $runnerlist, $link);
}
// Fichier HTML
function runnerlist($lang, $runnerlist, $link) {
if ($runnerlist != '') {
echo '<br/><br/>';
$restriction = array('id');
$entete = array(
nom=>constant('_PREFIXnom'),
prenom=>constant('_PREFIXprenom'),
naissance=>constant('_PREFIXnaissance'));
classement_html::tableau($runnerlist, $entete, $restriction);
}// fin du if
}// fin fonction coureur
// Fonction création d'un tableau
function tableau($list, $entete, $restriction){
echo '<table width="100%" border="0" cellspacing="10" cellpadding="0">'."\n";
//l'entete du tableau
echo '<tr>';
foreach($entete as $libelle){
echo '<td>' . $libelle . '</td>';
}
echo '</tr>';
//les donnees
//les lignes
while(list(, $objet) = each($list)){
echo '<tr>';
//les colonnes à partir de l'entête
foreach($objet as $name => $value) {
if(!in_array($name, $restriction)) {
echo '<td>' . $value . '</td>';
}
}
echo '</tr>';
}
echo '</table>';
}
[/php]
Puis-je encore améliorer mon résultat ?
Merci