问题在超链接中使用php变量 [英] Issue with using php variable in hyperlink
本文介绍了问题在超链接中使用php变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在另一个php变量的超链接中使用一个php变量作为url?下面是我的代码,显然不工作。
How do you use one php variable for the url in a hyperlink around another php variable? Below is my code, which is clearly not working. I want $url to be the hyperlinked text of $songTitle.
if ($result) {
$numberOfRows = $result->num_rows;
for($i=0; $i < $numberOfRows; $i++) {
$row = $result->fetch_assoc();
echo '<tr>';
echo '<td>' . $row['artistName'] . '</td>';
echo '<td>'<a href=". $row['url'] . > . $row['songTitle'] . </a> '</td>';
echo '<td>' . $row['yOR'] . '</td>';
echo '</tr>';
}
}
推荐答案
对于($ i = 0; $ i <$ numberOfRows; $ i ++){
$ row = $ result- $ p
You are not concatenating your strings properly.
for($i=0; $i < $numberOfRows; $i++) {
$row = $result->fetch_assoc();
echo '<tr>';
echo '<td>' . $row['artistName'] . '</td>';
echo '<td><a href="' . $row['url'] . '" >' . $row['songTitle'] . '</a></td>';
echo '<td>' . $row['yOR'] . '</td>';
echo '</tr>';
}
这篇关于问题在超链接中使用php变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文