Select PHP + Mysql

0

I'm new to web programming and I'm having trouble creating a CRUD, the insert worked OK, but the next step is that SELECT is not running as it should and I'd like you to help me see which one is being my mistake. I'm doing this:

<?php 
$conect = mysqli_connect('127.0.0.1','root','');
$db = mysqli_select_db($conect, 'Crud');
$query_select = "SELECT altura, cpf, endereco, nascimento, nome, peso  FROM Cliente";                
$select = mysqli_query($conect, $query_select);
$fetch = mysqli_fetch_row($select);
while ($fetch = mysqli_fetch_row($select)) {
    echo "<p>".$fetch[0]."</p>";
}
?>
    
asked by anonymous 06.06.2016 / 06:26

1 answer

0

The problem is that you get the first value of the query before and do nothing, while it takes the value below and the first value is "lost".

<?php 
    $conect = mysqli_connect( '127.0.0.1', 'root', '' );
    $db = mysqli_select_db( $conect, 'Crud' );
    $query_select = "SELECT altura, cpf, endereco, nascimento, nome, peso FROM Cliente";
    $select = mysqli_query( $conect, $query_select );
    while( $fetch = mysqli_fetch_row( $select ) )
    {
        echo $fetch[0];
    }
?>

It is good to check if the query was executed successfully before processing if( $select ) .

    
06.06.2016 / 06:41