Adding Field Names to a Drop Drop down list?

I’m trying to add Field Names to a drop down list, I previously added values to a drop down list and that worked, but for some reason its not doing anything when I’m trying to add the Field Names to a drop down list.

$result3=mysql_query(“SELECT * FROM bf2stats WHERE match_id=’$match_id’”);

echo “

”;
echo “”;
echo “(Change Player)”;
while($fldb = mysql_fetch_field($result3))
{
if ($fldb->name!=‘match_id’ && $fldb->name!=‘game_result’)
{
$m=(fldb>name);
echo “$m”;
}
}
echo "

Are you sure that this query return results?

I see several in your code, did you copy it from real source?

It returns results, it returns everything where match id is equal to a certain value.

ie if match_id=1 it return all the fields for that row.

What results you see with this code:

[php]
$result3=mysql_query(“SELECT * FROM bf2stats WHERE match_id=’$match_id’”);

echo “

”;
if (mysql_num_rows($result3)){
echo “”;
echo “(Change Player)”;
while($fldb = mysql_fetch_object($result3))
{
if ($fldb->name!=‘match_id’ && $fldb->name!=‘game_result’)
{
$m = $fldb->name;
echo “$m”;
} else {
echo “$m !tests!”;
}
}
echo “”;
}else {
echo ‘no matches’;
}
echo “”;
[/php]

If you have unexpected results, experiments will help to understand why you have it.
Your example code contain syntax errors - I think that you didn’t copy it from real example. May be there are logical errors, for this errors I need to see table dump with sample data.

What syntax errors did I have?

Run your example and you will see (copy&paste it).

More I think that I see logical error:

You use mysql_fetch_field see docs for this function http://bg.php.net/mysql_fetch_field it return an “info object” not row. I think that you mean ‘mysql_fetch_object’.

No all I want it to return is the field name which I then compare to see if its not one of those I dont want shown.

Your example failed to work and just gave me a blank option under the first option.

You have this field name for all rows in dataset.
You need sql facility for ‘field exclusion’:

SELECT field_name, field_name2 and so on.

Petty_Crim wrote:

No all I want it to return is the field name which I then compare to see if its not one of those I dont want shown.

Your example failed to work and just gave me a blank option under the first option.

Ok, see you even say it yourself… EXAMPLE!!! A lot code that people put up isn’t meant to be working. Its just a guide. You need to help yourself before we can help you. We aren’t here to write code for you.
Trial and Error is some of the best medicine.

I am not trying to be jerk, but why should we sit and put effort into fixing your problems when you seem to not do so yourself.

Right. You have clearly not tried debugging. Go do that first.

I worked this one out myself, thx anyway for the help though.

Sponsor our Newsletter | Privacy Policy | Terms of Service