doupacan2098 2019-07-12 18:40
浏览 90

如何编写数据库查询代码Joomla文章?

I am new to Joomla and want to access the #__facileforms_subrecords table from within the article editor and display selective elements.

I have tried the code shown taken from online searches and entered using the CodeMirror editor but it doesn’t recognise it as code.

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('*')
      ->from($db->quoteName('#__facileforms_ 
     //->where($db->quoteName('username') . " = ". $db->quote($user->username));
      ->where($db->quoteName('name') . " = user_id"));
$db->setQuery($query);

$rows = $db->loadObjectList();

echo '<table>';
echo '<tr>';
echo '  <th>Article Name </th>';
echo '  <th>Report Data </th>';
echo '</tr>';  
      foreach($rows as $row) {
          echo '<tr><td>' . $row->name . '</td><td>' . $row-    >report_data . '</td></tr>';
  }
echo '</table>';

I hoped to show the entries from the name column in the facileforms_subrecords table containing the word user_id. All I got was the entered code except for the echo’s of Article Name and Report Data. Please note this is an initial test code only to establish something that works so doesn’t represent a finished example. The queries and echo’d headings will be more relevant in the final effort.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?