While this is a too basic question, here’s a possible solution. You only have to check the second variable, the first one is okay even if it’s 0:
<?php
$result = mysql_query("SELECT * FROM high ORDER BY Runecraftlvl DESC LIMIT 20");
while($row = mysql_fetch_array($result))
{
echo ($row['deaths'] != 0) ? $row['kills'] / $row['deaths'] : '-';
echo "<br />";
}
?>
PD, it uses the ternary operator.
I found a post where it explains how to do what you requested. For your particular request, this is also important: How to avoid the “divide by zero” error in SQL?
3
solved PHP divide 2 values & echo 1 divided value [closed]