0

I have two tables from my DB which were retrieved with the following MYSQL SELECT statement:

SELECT table_schema AS database_name,
    table_name
FROM information_schema.tables
WHERE table_type = 'BASE TABLE'
    AND table_name LIKE 'cu%'
ORDER BY table_schema,
     table_name;

My goal is to get the values from these two tables and export them to HTML tables (one HTML table for each corresponding returned table) via PHP PDO. The tables have been returned but how can I access the rows?

2
  • Just to observe that this kind of thing is sometimes symptomatic of poor schema design Commented Jan 31, 2021 at 14:04
  • Thank you for your comment @strawberry, this let me rethink the design. Commented Jan 31, 2021 at 14:39

1 Answer 1

1
  1. First execute query in mysql if your query is producing your required output.
  2. put the query in php code.
  3. Use whileLoop to print number of rows in table. your Table html code should be ready.
  4. put the proper column name from your schema in place of tableColumnOne,---Two,---Three. Code:
$result = mysqli_query($conn,"your query");
while($row = mysqli_fetch_assoc($result))
{
    echo '<tr><td>'.$row['tableColumnOne'].'</td>
            <td>'.$['tableColumnTwo'].'</td>
            <td>'.$['tableColumnThree'].'</td>
        </tr>';
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.