How to load a mysql table with php?

0

Good morning, I'm new to php, I need to load a complete table that is in my mysql database and show it as a table with its header and everything on my website, if you could help me, thanks?

    
asked by Andy Montalvo 19.02.2018 в 16:34
source

1 answer

0

In principle, I think you should use PDO, that if you are using a php. If you use a Laravel framework, things change a bit but are easier.

In principle the example could be like this:

<?php
function getFruit($conn) {
    $sql = 'SELECT name, color, calories FROM fruit ORDER BY name';
    foreach ($conn->query($sql) as $row) {
        print $row['name'] . "\t";
        print $row['color'] . "\t";
        print $row['calories'] . "\n";
    }
}
?>

You can find it here , I would suggest you check the PDO documentation in the following link .

I hope I could help you.

Greetings.

    
answered by 19.02.2018 в 17:31