Q:

how can i show sql concat on my web with php

first my code: 
$con = mysqli_connect("****", "*****", "*****", "practica");

if(!$con){
    die ('no se conecta revisa lo primero');
}

if ($resultado = mysqli_query($con, "SELECT concat(text,text2) AS concatenado FROM valors")){
    echo "rows: ". mysqli_num_rows($resultado);
}
mysqli_close($con);

how can i show on my webpage the number of rows? it shows nothing, also how can i make to show every
concat from these to column tables (text,text2)? every one have 10 inserts and i need to show it, thanks

A:

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

$sql = "select concat(text,text2) AS concatenado from valors";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
  // output data of each row
  echo "rows: " . $result->num_rows;
} else {
  echo "0 results";
}

$conn->close();

I am sure that it will work for you

