Skip to content
Advertisement

showing contents of a table using PHP in HTML

I have this code snippet:

JavaScript

and

JavaScript

both inside submit.php, however, while the feedback table inside judges database is not empty, I don’t see any of the rows shown in the HTML page only the column name shows up in the Response tab of Network tab in Firefox Inspect tool. What do you suggest to populate the existing database into the html page even before I enter the information for the new user?

Here’s my feedback table from the judges database:

enter image description here

Trying the following from the comments also didn’t work and nothing got printed:

JavaScript

enter image description here

Advertisement

Answer

There’s no point in the if statement. You have PDO::ERRMODE_EXCEPTION enabled, so if there’s an error in the query it will throw an exception, not return false.

The syntax to fetch a row in PDO is $result->fetch(PDO::FETCH_ASSOC).

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement