【发布时间】:2023-03-29 16:30:02
【问题描述】:
我所做的只是在我的 joomla 网站中安装了 flexi 自定义代码模块以使用 php,我创建了一个新数据库而不是 joomla 数据库,并将代码如下所示连接并给出结果。
$rows = $result->num_rows; // Find total rows returned by database
if($rows > 0) {
$cols = 3; // Define number of columns
$counter = 1; // Counter used to identify if we need to start or end a row
$nbsp = $cols - ($rows % $cols); // Calculate the number of blank columns
$container_class = 'container-fluid'; // Parent container class name
$row_class = 'row'; // Row class name
$col_class = 'col-sm-4'; // Column class name
echo '<div class="'.$container_class.'">'; // Container open
while ($item = $result->fetch_array()) {
if(($counter % $cols) == 1) { // Check if it's new row
echo '<div class="'.$row_class.'">'; // Start a new row
}
$jid=$item['jid'];
$jdesc = $item['jdesc'];
$duration=$item['duration'];
$jobtitle=$item['jobtitle'];
echo ('<div class="'.$col_class.'">'.'<h3>'.'<a href="showjob?jid=' . $jid . ' ">' .$jobtitle . '</a>' .'</br>'.$jdesc.'<br/>'.$duration.'</h3>'.'<h5>'.$item['name'].'</h5></div>');
if(($counter % $cols) == 0) { // If it's last column in each row then counter remainder will be zero
echo '</div>'; // Close the row
}
$counter++; // Increase the counter
}
$result->free();
if($nbsp > 0) { // Adjustment to add unused column in last row if they exist
for ($i = 0; $i < $nbsp; $i++) {
echo '<div class="'.$col_class.'"> </div>';
}
echo '</div>'; // Close the row
}
echo '</div>'; // Close the container
}
?>
<?php
$conn->close();
?>
它已创建数据库连接并给出了结果,但我想将参数发送到其他模块以显示结果如何将参数从一个模块发送到另一个模块, 最后我想在单击链接时将 id 值放入另一个模块
【问题讨论】:
-
您是在谈论模块参数还是您从数据库中获取的结果集?
-
我正在谈论从数据库中获取的 jid 值,以传递给另一个模块,该模块是我在 joomla 中使用菜单创建的另一个页面 showjob 页面
-
那么,将其保存在会话中/通过 GET 或 cookie 发送?不确定我是否看到了问题
-
你能把我的代码发给我吗
-
不,我不会为您编写代码,如果您是新手,那么最好的学习方式就是自己动手。查看
header(Location:)并向其添加 GET 参数。