Log in

View Full Version : Need a profilefield in a SQL query in memberlist.php


ganima
10-19-2009, 06:43 PM
Hi, there is a little query that drives me nuts ;) I can't get it working.

In /memberlist.php I want the letter links (# A-Z) to look in a custom field not in username.
At line 337 I changed the code to ?
if ($ltr != '')
{
if ($ltr == '#')
{
if ($sortfield == 'nachname')
{
$condition .= "field7 NOT REGEXP(\"^[a-zA-Z]\")";
}
else
{
$condition .= "username NOT REGEXP(\"^[a-zA-Z]\")";
}
}
else
{
$ltr = chr(intval(ord($ltr)));

if ($sortfield == 'nachname')
{
$proffid = $profilefield[profilefieldid][7];
$condition .= $proffid.' LIKE("' . $db->escape_string_like($ltr) . '%")';
}
else
{
$condition .= 'username LIKE("' . $db->escape_string_like($ltr) . '%")';
}
}
}

? but the profilefieldid is always empty. I even can not change it to
$condition .= 'field7 LIKE("' . $db->escape_string_like($ltr) . '%")';
That makes a SQL error and says there is no field named field7.

What's wrong with that? How do I have to change my code to get the profilefield #7 to look at?

Hope for help. And thanks!

Lynne
10-19-2009, 06:58 PM
This line:
$proffid = $profilefield[profilefieldid][7];

Where is $profilefield defined? Are you sure that variable is correct cuz it looks a bit odd to me ($profilefield[profilefieldid][7]? I would have thought $profilefield[fieldid7], but I don't know your queries).

ganima
10-20-2009, 06:04 AM
I am pretty unsure that the variable is correct. I really don't know where or how to look at.

This line$condition .= 'field7 LIKE("' . $db->escape_string_like($ltr) . '%")';
should look in the profilefield id 7 (that is where I store users lastname).

But the query (whereever it is build) doesn't search in there. Hope for someone who is more comfortable with the code in vB.