More questions:
- Why does the second sqlSelect statement not have a $mydb reference? At the best you are being inconsistent.
- 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.
- You should separate getting the data into %ARTICLE from its presentation in HTML. i.e. separate the Model from the View
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->sqlS
+elect1("ref_enchereur,id_enchere", "enchere", "ref_article = '$articl
+e' AND prix = $ARTICLE{'max_enchere'}");
# why is this not $mydb->sqlSelect1 like above?
my @result = sqlSelect("nom_utilisateur,email,lang,adresse,vil
+le,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&p
+age=profil_vendeur&username=$ARTICLE{'nom_utilisateur_acheteur'}" cla
+ss="menulink">
$ARTICLE{'nom_utilisateur_acheteur'}</a></label>
</td>
EOF
return $string;
}
If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)