note
space_monk
More questions:
<ol>
<li>Why does the second sqlSelect statement not have a $mydb reference? At the best you are being inconsistent.
<li>The following code will not handle undefined items gracefully. I hope the database can be guaranteed to return empty strings if no data is present for fields.
<li>You should separate getting the data into %ARTICLE from its presentation in HTML. i.e. separate the Model from the View
</ol>
</p>
<code>
sub getLastEnchereurDetail {
my $article = $query->param("article");
my $ref_max_enchereur;
my $max_enchere;
($ARTICLE{'max_enchere'})=$mydb->sqlSelect1("MAX(prix)", "enchere", "ref_article = '$article'");
if ($ARTICLE{'max_enchere'} ne '') {
($ARTICLE{'max_enchereur'},$ARTICLE{'id_enchere'})=$mydb->sqlSelect1("ref_enchereur,id_enchere", "enchere", "ref_article = '$article' AND prix = $ARTICLE{'max_enchere'}");
# why is this not $mydb->sqlSelect1 like above?
my @result = sqlSelect("nom_utilisateur,email,lang,adresse,ville,npa,no_telephone,nom,prenom", "personne", "id_personne = '$ref_max_enchereur'");
($ARTICLE{'nom_utilisateur_acheteur'},$ARTICLE{'email_acheteur'},
$ARTICLE{'acheteur_lang'},$ARTICLE{'acheteur_adresse'},
$ARTICLE{'acheteur_ville'},$ARTICLE{'acheteur_npa'},
$ARTICLE{'acheteur_telephone'},$ARTICLE{'acheteur_nom'},
$ARTICLE{'acheteur_prenom'})= @result;
}
my $string =<<EOF;
<td align="left" width="200"><label id="label_category_name">$SERVER{'last_enchereur'}</label></td>
<td align="left">
<a href="/cgi-bin/recordz.cgi?lang=$lang&session=$session_id&page=profil_vendeur&username=$ARTICLE{'nom_utilisateur_acheteur'}" class="menulink">
$ARTICLE{'nom_utilisateur_acheteur'}</a></label>
</td>
EOF
return $string;
}
</code>
<div class="pmsig"><div class="pmsig-880879">
If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)
</div></div>
1036073
1036121