I create a function to call some data from database with left-join and prepare statement.

Here is the sketch of the php function: 

```
function getStock()
{
    global $mysqli;
        $stmt = $mysqli->prepare 
            ("SELECT     products.`product_name`, product_category.`price`
              FROM products    
                LEFT JOIN  product_category
                ON         products.product_category_id = product_category.id

                WHERE      products.id = ?");

    $id=3; 
    $stmt->bind_param("s", $id);
    $stmt->execute();
    $stmt->fetch();
    return $stmt;

```

In the view page I do this: 

```
    $resultsTicket = getStock();
    $results = $resultsTicket->num_rows;
    var_dump($results);
    if ($resultsTicket->num_rows > 0) {
        while($resultsTicket->fetch()){

```

However in the var\_dump I only get int(0) 

I don't know anymore how to find the error there beside the var\_dump. Please help me in the above code. Thank you! 

**[UPDATE]**

```
$query = "SELECT     products.`product_name`, product_category.`price`
          FROM       products    
          LEFT JOIN  product_category
          ON         products.product_category_id = product_category.id
          WHERE      products.id = 3;

if ($stmt = $mysqli->prepare($query)) {     
    $stmt->execute();
    $stmt->bind_result($product_name, $price);
    //$stmt->fetch();
    while ($stmt->fetch()) {
    printf ("%s (%s)\n", $product_name, $price);
    }   
        $stmt->close();}
    return $stmt;

}

```

In the code above I get one data/row from database.