Answer the question
In order to leave comments, you need to log in
Question about the each method?
My database query selects only one record. Next, I encode it in JSON. And I pass it to the script.
Here is just the question. Do I need to use each, because I don’t seem to have an array, but one record, but I can’t access the property directly.
$.each(json.client_date,function() {
$('#changeClientDataForm')[0].reset();
$('#changeClientDataForm .code').val(this['code_client']);
$('#changeClientDataForm .name').val(this['name']);
$('#changeClientDataForm .login').val(this['login']);
$('#changeClientDataForm .password').val(this['password']);
});
Answer the question
In order to leave comments, you need to log in
So if you are sure that only one record is always selected from the database (search by key, for example), then you should rewrite the php code
$row = mysql_fetch_array($result, MYSQL_ASSOC))
echo json_encode(array("client_date" => $row));
$('#changeClientDataForm')[0].reset();
$('#changeClientDataForm .code').val(json.client_date.code_client);
$('#changeClientDataForm .name').val(json.client_date.name);
$('#changeClientDataForm .login').val(json.client_date.login);
$('#changeClientDataForm .password').val(json.client_date.password);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question