I'm attempting to use the "fetch_assoc" functionality in order to collect all the "blog" fields of all the rows in my table.
At the moment, it sort of works; it collects the contents of the first "blog" field in the first row, however for every other row it collects the same data from the first row.
So, for example, this is the code I'm using:
$connection = new mysqli($host,$user,$pass,$db);
$result = $connection->query("SELECT * FROM `Blogs`");
$blogs = array();
$max = sizeof($blogs);
while( $row = $result->fetch_assoc() ) {
$blogs[] = $row['Blog_Contents'];
for ($x = 0; $x <= $max; $x++) {
echo ("<div align=center> <div class=container> <div class='well well-lg wow bounceIn' data-wow-delay='.1s'>" . $blogs[$x] . "</div> </div> </div>");
}
}
There are four rows in the table as of now- so row one would have:
Hello this is blog number 1 of the test scheme
Row two would have:
Hello this is blog number 2 of the test scheme
And the same for 3 and 4, with the number in the blog increasing with it's index.
At the moment, my code is producing the following result:
Hello this is blog number 1 of the test scheme
Hello this is blog number 1 of the test scheme
Hello this is blog number 1 of the test scheme
Hello this is blog number 1 of the test scheme
Could anyone please tell me why my code isn't reading the other Blog_Contents?
And maybe tell me how to rectify the code?
Sorry if I wasn't explaining it very well; I have tried to research this as much as I could but couldn't find what I needed. Thanks in advance,
Sparkhead95