SELECT in MYSQL resulting in only one record

Asked

Viewed 26 times

1

I make a SELECT direct from the Phpmyadmin panel:

SELECT `tx_type` FROM `tx_ar_tax` WHERE `tax_ref` = '75639' AND `tax_order` = 'O';

phpMyAdmin returns 7 records as registered and correct

inserir a descrição da imagem aqui

But in PHP output only one value comes out in ARRAY:

<?php
$sql_tx = "SELECT `tx_type` FROM `tx_ar_tax` WHERE `tax_ref` = '75639' AND `tax_order` = 'O';";

$q_tx = mysqli_query($conn,$sql_tx);

$tx = mysqli_fetch_array($q_tx, MYSQLI_ASSOC);
echo "<pre>";
print_r($tx);
echo "</pre>";

Array
[
    [tx_type] => 'ax-1069c'
]

1 answer

2


The mysqli_fetch_array will return you only the array. If you want to show the others you should put in a while.

while($tx = mysqli_fetch_array($q_tx, MYSQLI_ASSOC)){
    echo "<pre>";
    print_r($tx);
    echo "</pre>";
}
  • 1

    Thanks X4vier for the help, it worked out here ! abs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.