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>';
}
}
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>';
}
did you copy your script from somewhere? In parts of it you seem to understand how to escape and use PHP values inside a string, but then you messed up the one line.
Anyway, this is it fixed.. you didn't have your quotes or single quotes used properly.
echo "<td><a href='". $row['url'] . "'>" . $row['songTitle'] ." </a> </td>";