我的数据库图片
http://www.m-iau.ac.ir/db.jpg http://www.m-iau.ac.ir/db.jpg
这是我的PHP代码
$user = JFactory::getUser();
$db = JFactory::getDbo();
$userId = $user->get('email');
// Is the user logged in?
if ($userId) {
// Grab the value from the database.
$db->setQuery("SELECT `value` FROM `#__facileforms_subrecords` WHERE `value` like '09%' GROUP BY `record` HAVING `record`='".$userId."'");
return $db->loadResult();
}
在表格中,任何用户添加都有相同的记录(列),我只想在此表中显示用户记录
答案 0 :(得分:0)
如果要获取属于当前用户的所有行,请先获取用户ID:
$user = JFactory::getUser();
$id = $user->id; // or $user->get('id');
然后创建查询:
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName('value'))
->from($db->quoteName('#__facileforms_subrecords'))
->where($db->quoteName('record')."=".$db->quote($id));
$db->setQuery($query);
$results = $db->loadRowList(); // loadObjectList() or whatever you need
然后您将获得属于当前用户的所有值。