Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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>';
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
170 views
Welcome To Ask or Share your Answers For Others

1 Answer

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>';
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...