Reputation: 227
I have the code below:
$result = mysql_query("SELECT link, notes FROM links WHERE username='will';");
$html .= "<ul>";
while ($row = mysql_fetch_array($result)) { //loop
extract($row);
$html .= "<li>{$link} - {$notes}</li>";
}
I need the bit where it says {$link}
to become a clickable link which opens a new window. How would I do this?
When I put tags around it you get this error:
The error is: Parse error: syntax error, unexpected '{' in /data/www/vhosts/themacsplash.com/httpdocs/ClipBoy/will.php on line 18
Line 18 is $html .= "<li>{$link} - {$notes}</li>";
Upvotes: 1
Views: 660
Reputation: 1724
if your $link contains an url in the form "http://www.example.com/", use this:
$html .= "<li><a href=\"{$link}\">{$notes}</a></li>";
Upvotes: 0
Reputation: 15959
First create a correct code and make error handeling, than set variables outside quotes.
$qry = "SELECT link, notes FROM links WHERE username='will'";
$mysqlqry = mysql_query($qry);
if($mysqlqry){
if(mysql_num_rows($mysqlqry) > 0){
$html .= "<ul>";
while($row = mysql_fetch_array($result)) { //loop
extract($row);
$html .= "<li><a href=". htmlentities($link) .">". $notes ."</a></li>";
}
}
}
Upvotes: 0
Reputation: 387557
In general you make a link like this: <a href="URL">link title</a>
. So in your case like this:
$html .= "<li><a href=\"{$link}\" target=\"_blank\">{$link}</a> - {$notes}</li>";
Upvotes: 4