简体   繁体   中英

Get values from DBs with specific prefix - MySQL/PHP

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?

  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>';
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM