I've managed to tweak a script to get it to parse a database to see if one field contains a given word (say, the country France) and, where there's a match, to print out a different field (say, the user's name). The code is below.
What I'd love to figure out is to then sort the list of users' names alphabetically? Does anyone have a piece of script I could borrow (and try to learn from).
A side thought: if one user has two records, both of which include the keyword of France, is there a way of displaying the user's name just the once?
TIA,
Andy
* * *
&open_file("FILE1","","$basedir$filename");
$line = &read_file("FILE1");
$counter = 0;
while (($line = &read_file("FILE1")) && ($counter < 120)) {
# split the fields at the | character
@tabledata = split(/\s*\|\s*/,$line,$fields);
#see if the category allocated field matches the one called for in the querystring
if ($tabledata[4] =~ /^$category/i) {
#see if the market field also includes the one called for in the querystring
@words = split(/\s*\,\s*/,$tabledata[14]);
foreach $aword (@words) {
if ($query =~ /\b$aword/i) {
# print list of directory entry titles from the records -- table definition not included in this posting to save space
print "<TR valign=top><TD class=bodyfull ALIGN=center>$tabledata[2]</TD></TR>\n";
$counter++;
}
}
}
}
[This message has been edited by Andy (edited November 07, 1999).]
What I'd love to figure out is to then sort the list of users' names alphabetically? Does anyone have a piece of script I could borrow (and try to learn from).
A side thought: if one user has two records, both of which include the keyword of France, is there a way of displaying the user's name just the once?
TIA,
Andy
* * *
&open_file("FILE1","","$basedir$filename");
$line = &read_file("FILE1");
$counter = 0;
while (($line = &read_file("FILE1")) && ($counter < 120)) {
# split the fields at the | character
@tabledata = split(/\s*\|\s*/,$line,$fields);
#see if the category allocated field matches the one called for in the querystring
if ($tabledata[4] =~ /^$category/i) {
#see if the market field also includes the one called for in the querystring
@words = split(/\s*\,\s*/,$tabledata[14]);
foreach $aword (@words) {
if ($query =~ /\b$aword/i) {
# print list of directory entry titles from the records -- table definition not included in this posting to save space
print "<TR valign=top><TD class=bodyfull ALIGN=center>$tabledata[2]</TD></TR>\n";
$counter++;
}
}
}
}
[This message has been edited by Andy (edited November 07, 1999).]