问题
I have a query like
SELECT *
FROM membermetas
WHERE memberId =15
Table image :

and my php code is
$memberMetaQuery = "select * from membermetas where memberId='$id'";
$getMemberMeta = mysql_query($memberMetaQuery);
$memberMetaRow = mysql_fetch_array($getMemberMeta);
when i use "echo $memberMetaRow['memberMeta']
" without while loop, it turns the last row.
For example:
i would like to use only the row "eposta
" and its value "mail@mymail.com
"
is there any selector for this?
I think that, maybe i can use like $memberMetaRow['memberMeta']['eposta']
but it's not working as you know :)
How can i get this meta value without using mysql query?
is this possible with a php selector?
回答1:
if you are ready to mention eposta manually like
$memberMetaRow['memberMeta']['eposta']
THEN its better to append query to
$memberMetaQuery = "select * from membermetas where memberId='$id' and memberMeta='eposta'";
Infact this can be use useful a function like
function call_data($id,$name){
$memberMetaQuery = "select * from membermetas where memberId='$id' and memberMeta='$name'";
$getMemberMeta = mysql_query($memberMetaQuery);
$memberMetaRow = mysql_fetch_array($getMemberMeta);
return($memberMetaRow);
}
THEN you can call
$data = call_data(15,'eposta');
来源:https://stackoverflow.com/questions/21326557/php-get-meta-value-by-using-meta-key-from-mysql