php - Check if a row exists in database and if not display a message -


hi guys can't manage check if row exists in database , if not display message. code bellow. need little help. thx

<?php     $result = mysqli_query($mysqli, "select client_cv formular_client id = '$id'");     if (mysqli_num_rows($result) > 0){        echo "<a href='../cv/" . $rows['client_cv'] . "' target='_blank' class='btn btn-lg btn-primary'><span class='glyphicon glyphicon-download-alt'></span> descarca cv</a>";    } else {        echo "<a href='#' target='_blank' class='btn btn-lg btn-primary'><span  class='glyphicon glyphicon-download-alt'></span> fara cv</a>";    } ?> 

if want show different links based on if client_cv has value or not, try this

<?php     $result = mysqli_query($mysqli, "select client_cv formular_client id = '$id'");      if (mysqli_num_rows($result) > 0){         $rows = mysqli_fetch_array($result);         if (strlen($rows["client_cv"]) > 0){             echo "<a href='../cv/" . $rows['client_cv'] . "' target='_blank' class='btn btn-lg btn-primary'><span class='glyphicon glyphicon-download-alt'></span> descarca cv</a>";         } else {             echo "<a href='#' target='_blank' class='btn btn-lg btn-primary'><span  class='glyphicon glyphicon-download-alt'></span> fara cv</a>";         }     } else {         echo "no record found"     } ?> 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -