SQL query returned as a variable in PHP

Jordi Ponts :

i've got this code and i would like to get it as an INT to be able to have it used as a counter to set the new id to introduce new data at 'plats' table. Anyone could help me please?

<?php
  include("conection.php");
  $consulta="SELECT count(id_plat) FROM `plats`";//consulta no plats actuals
  $resultat=mysqli_query($connect,$consulta);
  $row = mysql_fetch_assoc($resultat);
  echo $row;
  mysqli_close($connect);
 ?>
MiK :
<?php
  include("conection.php");
  $consulta="SELECT count(id_plat) FROM `plats`";//consulta no plats actuals
  $resultat=mysqli_query($connect,$consulta);
  $row = mysqli_fetch_row($resultat);
  $mycounter = (int)$row[0];
 ?>

Fetch the results with number-based index and assign the 0th index to a variable.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=297703&siteId=1