title: Placing of an IF in a query (MYSQL)
body: <p>Where should i put in an if in this query?
  I want that if the query returns empty the form is not shown but only a message like   "there is noting to correct in the table"
  is this hard to do by php?</p>
  
  <p>here is the code:</p>
  
  <pre><code>    //Step 2: Kjør en SQL-query to databasen 
  $sql  = "SELECT * FROM oppgave  WHERE modulid=4 AND resultat is NULL ORDER BY RAND() LIMIT 1";
  
  $data = null;
  $dataid = null;
  $result = mysql_query($sql, $tilkobling); 
  echo "&lt;hr&gt;";
  while ($nextrow= mysql_fetch_assoc($result)){
  echo "Besvarelse: " . $nextrow['besvarelse'];
  echo "&lt;br&gt;Modulid: " . $nextrow['modulid'];
  //echo "&lt;br&gt;student: " . $nextrow['studentid'];
  echo "&lt;br&gt;";
       $data = $nextrow['modulid'];
       $dataid = $nextrow['id'];
  }
  
  
  
  //Skjema til utfylling mot database
  echo '&lt;form name="input" action="tilretting.php" method="post"&gt;';
      echo'Retter&lt;input type="text" name="correctedby" value="'.$_SESSION['myusername'].'"&gt;';
      echo '&lt;input type="hidden" name="resultat" value="0"&gt;';
      echo 'Godkjent&lt;input type="checkbox" name="resultat" value="1"&gt;';
      echo 'modul&lt;input type="text" name="modulid" value="'.$data.'"&gt;';
       echo 'id&lt;input type="text" name="id" value="'.$dataid.'"&gt;';
      echo '&lt;input class="levermodulknapp" type="submit" name="lever1" value="Send inn retting"&gt;';
      echo  "&lt;/form&gt;";
      echo "&lt;hr&gt;";
  ?&gt;
  </code></pre>