2
Friends reissued the PDO connection below:
<?php
$conn = new PDO( 'mysql:host=localhost;dbname=pbfjacar_site' , 'pbfjacar_murilo' , 'smc100164' );
$stmt = $conn-> prepare('SELECT font FROM fontes');
$stmt-> execute();
$result = $stmt-> fetchAll(PDO::FETCH_ASSOC);
?>
To execute this new operation:
<select name="tipo_font_end">
<?php foreach( $result as $row ) ?>
<option value="<?php echo $row['font'];?>"><?php echo $row['font'];?></option>
</select>
But I’m not getting the expected result, because it now pulls only the last "ID" of a total of 10 entries in the table "sources", as shown below:
I’m entering the test access address below, so you can see what’s going on! http://www.pbfjacarepagua.com.br/teste/end.php
If friends can show me where I am going wrong or even what is missing, I would be very grateful. Hugs to all.
Your
<select>
no loop?– Papa Charlie
Friend what would be loop? I am very lay in php.
– Murilo Cabral
Before that line
return $result;
put thisvar_dump($result);
, if possible edit your response with the result, ok?– Papa Charlie
It didn’t work!!! Enter the address (http://www.pbfjacarepagua.com.br/teste/end.php), and see the result. The code looks like this:
<?php
 $conn= new PDO("mysql:host=localhost;dbname=site", "root", "");
$count = 'SELECT * FROM fontes';
$stmt = $conn->prepare($count);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
var_dump($result);
return $result;
foreach($result as $res)
?>
– Murilo Cabral
Murilo, I noticed that you have completely edited your publication, which has misread a question that could be useful to others, because now whoever enters here will see things totally out of context. If any answer solved your problem you can mark as solved (do not need to put SOLVED in the title) and add information in the comments. If you’ve solved it yourself, create your own answer. But it’s good to always keep your initial question.
– Paulo Rodrigues
I’m sorry Paul, it won’t happen again.
– Murilo Cabral