【问题标题】:Concatenating a MySQL query and text连接 MySQL 查询和文本
【发布时间】:2011-02-07 09:00:53
【问题描述】:

我有密码

$link = "group.php?=";
$fulllink;
while($row = mysql_fetch_array($result))
{
  $other = $link.$row;
  echo $row;
  echo "<a href = \"$other\"> $row[mygroup] </a>";
  echo "</br>";
}

我想链接到每个组的 group.php 页面(例如 group.php?=samplegroup)。但是,mysql_fetch_array 返回一个数组,我无法将其连接到 $link 变量。我该怎么办?

【问题讨论】:

  • $other = $link . $row['mygroup']

标签: php mysql concatenation


【解决方案1】:

你只需要访问数组:

$other = $link.$row['mygroup'];

(或任何数组键)

你的代码更好一点:

<?php
// other code
$link = "group.php?=";
?>

<?php while(($row = mysql_fetch_array($result))): ?>
    <a href="<?php echo $link, $row['mygroup']; ?>">
        <?php echo $row['mygroup']; ?>
    </a>
    </br>
<?php endwhile; ?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-06
    • 1970-01-01
    • 2021-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-21
    • 1970-01-01
    相关资源
    最近更新 更多