How to print field (column) from table in MySQL with PHP and SQL

1 Answer

0 votes
$con = new PDO("mysql:dbname=database_name;host=localhost", "user_name", "password");

$sql = $con->prepare("SELECT * FROM table_name");
$sql->execute();

while ($row = $sql->fetch(PDO::FETCH_ASSOC)) {
	echo $row['column_name'] . "<br>";
}



/*
run:


data
data
data
...

*/

 



answered Nov 28, 2020 by avibootz

Related questions

1 answer 311 views
2 answers 385 views
1 answer 298 views
1 answer 272 views
...