Does this not work? or am I just doing it wrong? Tried multiple variations of it, and can’t seem to find any solid info on the subject. any ideas?
$given_id = 1;
while ($row = mysql_fetch_array($sql))
{
if ($i < 10){
$display = '<a href="' . $row['info'] . '" onMouseOver="' . if($row['type']=="battle"){ . 'showB' . } else { . 'showA'() . "><div class="' . $row['type'] . "_alert" . '" style="float:left; margin-left:-22px;" id="' . $given_id . '"></div></a>';
if is a self standing statement. It’s a like a complete statement. So you can’t use it in between concatenetion of strings or so.
The better solution is to use the shorthand ternary operatior
This can be used in concatenation of strings also. Example :
You can use nested ternary operator also: