I am having some problems with this because I am new to php. I think the direction is clear enough that you guys may be able to help. Lets assume I have 3 fields in test.users
Those fields are: id, name, pass.
Here is the code:
<--- Begin Code---->
$connection = mysql_connect( $dbhost, $dbuser, $dbpass);
$db = mysql_select_db(test);
$fields = mysql_list_fields("test", "users", $connection)
$columns = mysql_num_fields($fields);
$sql = "SELECT * FROM users where id = 1";
$Result = mysql_query( $sql ) or die( mysql_error() );
while ($row = mysql_fetch_array ($Result)) {
for ($i = 0; $i < $columns; $i++) {
$field_name = @mysql_field_name
($fields, $i);
$field_value = $row["$field_name1"];
$field_name = $field_value;
}
}
echo $user;
<-----End Code----->
What I want is to grab the field name and set it as a variable and then set the field value of the current row to the field name variable (Did that make sense?). EX: Grab the field name user. Set it to a var of $user. Grab the value of user out of the db and set $user = value. So if I want to echo $user later on the page it prints the username of the id I grabbed. If I need to clarify I will do my best. The code I have does not work and I wanted to know what I can do to make it work.
Thanks,
--ick