I'm trying to create a PDO loop where I can choose the desired field to position it on the page. But the code I'm using is bringing all the fields in one go.
My code looks like this:
include("libraries/conn.php");
$sql = "SELECT
content.id_content,
content.img,
content.titulo,
povos.pv,
cat.categoria,
content.inicio,
content.fim,
content.content,
regiao.reg,
regiao.wmap
FROM cat
INNER JOIN regiao
INNER JOIN povos
INNER JOIN content ON povos.id_povos = content.civ
AND regiao.id_regiao = povos.regiao
AND cat.id_cat = content.clas
ORDER BY rand()";
$result = $PDO->query( $sql );
$rows = $result->fetchAll(PDO::FETCH_ASSOC);
print_r( $rows );
The result is coming like this:
Array ([0] => Array ([id_content] => 31 [img] => Paleozoic.jpg [title] = > Architecture and Housing [home] => -550000000 [end] = -250000000 [content] => The Paleozoic era prevailed from 550 to 250 million years ago, during which time the land surface underwent major transformations Among them are the emergence of mountainous clusters such as the Scandinavian Alps (Europe). This geological age is also characterized by the occurrence of sedimentary and metamorphic rocks, the formation of large forests, glaciers, first insects and reptiles. [reg] => World [wmap] => world.jpg)