Reputation: 79
below is my PHP code, I just can't figure out how to make the "INFO" text appear as a clickable url. I've seen the echo method but not one that works for the below. This method needs to create a link using the data and also set the link as the text used inside the table.
<?php
if(isset($data) && !empty($data)) {
foreach ($data as $row) {
@$count += 1;
$keyword = htmlspecialchars($row['Keyword']);
$suburb = htmlspecialchars($row['Suburb']);
$postcode = htmlspecialchars($row['Postcode']);
$status = htmlspecialchars($row['Status']);
$info = htmlspecialchars($row['Info']);
@$table_row .= "<tr><td>$count</td><td>$keyword</td><td>$suburb</td><td>$postcode</td><td>$status</td><td>$info</td></tr>";
}
echo @$table_row;
}
?>
It's the 'Info' column that i want to pull in as a url.
Cheers, Curtis http://www.homegiraffe.com.au
Upvotes: 2
Views: 81
Reputation:
you can use this
<?php
if(isset($data) && !empty($data)) {
foreach ($data as $row) {
@$count += 1;
$keyword = htmlspecialchars($row['Keyword']);
$suburb = htmlspecialchars($row['Suburb']);
$postcode = htmlspecialchars($row['Postcode']);
$status = htmlspecialchars($row['Status']);
$info = htmlspecialchars($row['Info']);
?>
<tr><td><?php echo $count;?></td><td><?php echo $keyword;?></td><td><?php echo $suburb;?></td><td><?php echo $postcode?></td><td><?php echo $status;?></td><td><a href="<?php echo $row['Info'];?>"><?php echo $info;?></a></td></tr>;
<?php
}
}
?>
and it work very good :)
Upvotes: 0
Reputation: 79
$info = '<a href="' . $row['Info'] . '">' . htmlspecialchars($row['Info']) . '</a>';
This is the answer. Thanks to Chris85 for the help!
Upvotes: 1