Be careful with the quotes / double quotes.
echo "<nm>".ucfirst($sd->fname)." ".ucfirst($sd->sname).'<input type="button" id="'.$sd->id.'" value="Add Friend" style="float:right;" onclick="alert(\'Clicky!\');" /><br></nm>';
Frage
What I'm doing wrong? I want to show an alert function or message, but it does not work:
echo"<nm>".ucfirst($sd->fname)." ".ucfirst($sd->sname)."<input type='button' id='$sd->id' value='Add Friend' style='float:right';' onclick='alert(\'Clicky!\')'/><br></nm>";
When I view the source, it looks like below
clicky!\')'="" onclick="alert(\" ;'=""
Lösung
Be careful with the quotes / double quotes.
echo "<nm>".ucfirst($sd->fname)." ".ucfirst($sd->sname).'<input type="button" id="'.$sd->id.'" value="Add Friend" style="float:right;" onclick="alert(\'Clicky!\');" /><br></nm>';
Andere Tipps
Something like this?
echo ("<a href='#' onclick='alert(\'Clicky!\')>" . ucfirst($sd->fname) . " " . ucfirst($sd->sname) . "</a>");