Austin Gayler
Austin Gayler

Reputation: 4376

Concatenating a MySQL query and text

I have the code

$link = "group.php?=";
$fulllink;
while($row = 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?

Upvotes: 0

Views: 1037

Answers (1)

Felix Kling
Felix Kling

Reputation: 817208

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

Upvotes: 1

Related Questions