开发者

Concatenating a MySQL query and text

I have the code

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

which I would like to link to each group's group.php page (such as group.php?=samplegroup). However, mysql_fetch_array returns an array, which I am unable to concatenate to the $link variable. What should I do?


You just have to access the array:

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

(or whatever the array keys are)

Your code a little bit nicer:

<?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; ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜