问题描述
我有一个类似的查询选择 *FROM membermetas
WHERE memberId =15
I have a query likeSELECT *FROM membermetas
WHERE memberId =15
表格图片:
我的php代码是
$memberMetaQuery = "select * from membermetas where memberId='$id'";
$getMemberMeta = mysql_query($memberMetaQuery);
$memberMetaRow = mysql_fetch_array($getMemberMeta);
当我使用 "echo $memberMetaRow['memberMeta']
" 而没有 while 循环时,它会转到最后一行.
when i use "echo $memberMetaRow['memberMeta']
" without while loop, it turns the last row.
例如:
我只想使用行eposta
"及其值[email protected]
"
有这个选择器吗?
For example:
i would like to use only the row "eposta
" and its value "[email protected]
"
is there any selector for this?
我认为,也许我可以像 $memberMetaRow['memberMeta']['eposta']
那样使用,但正如你所知,它不起作用 :)
I think that, maybe i can use like $memberMetaRow['memberMeta']['eposta']
but it's not working as you know :)
如何在不使用 mysql 查询的情况下获取此元值?
这可以用 php 选择器实现吗?
How can i get this meta value without using mysql query?
is this possible with a php selector?
推荐答案
如果你准备像
$memberMetaRow['memberMeta']['eposta']
然后最好将查询附加到
$memberMetaQuery = "select * from membermetas where memberId='$id' and memberMeta='eposta'";
事实上这可以使用像
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);
}
然后你可以打电话
$data = call_data(15,'eposta');
这篇关于php - 使用 mysql 中的元键获取元值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!