开发者

Concatenating a MySQL query and text

开发者 https://www.devze.com 2023-02-08 18:01 出处:网络
I have the code $link = \"group.php?=\"; $fulllink; while($row开发者_StackOverflow = mysql_fetch_array($result))

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

精彩评论

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