Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7704087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:36:22+00:00 2026-05-31T23:36:22+00:00

Alright, so I’m fairly new to PHP and SQL/MySQL so any help is appreciated.

  • 0

Alright, so I’m fairly new to PHP and SQL/MySQL so any help is appreciated.

I feel like I took the right approach. I searched php.net for “MySQL show all table names”, it returned a deprecated method and suggested using a MySQL query on SHOW TABLES [FROM db_name] [LIKE 'pattern'] I’m not sure what “pattern” means but, I searched for “SQL Wildcard” and got the “%” symbol. According to everything I found, this should work and output the table names at the end, but it does not. Any suggestions? Thanks in advance.

<?php
if ($_REQUEST["username"]=="coke"&&$_REQUEST["password"]=="pepsi"){
echo 'You have successfully logged in.';
echo '<br />';
echo 'These are your tables:';
echo '<br />';

   $link = mysql_connect("sql2.njit.edu", "username", "password");

   mysql_select_db("db_name") or die(mysql_error());

   $result = mysql_query('SHOW TABLES [FROM db_name] [LIKE '%']');
   echo $result;
}
else
echo 'You did not provide the proper authentication';
?>

I get no errors. The output is exactly what’s echoed, but no table names.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:36:24+00:00Added an answer on May 31, 2026 at 11:36 pm

    The square brackets in your code are used in the mysql documentation to indicate groups of optional parameters. They should not be in the actual query.

    The only command you actually need is:

    show tables;
    

    If you want tables from a specific database, let’s say the database “books”, then it would be

    show tables from books;
    

    You only need the LIKE part if you want to find tables whose names match a certain pattern. e.g.,

    show tables from books like '%book%';
    

    would show you the names of tables that have “book” somewhere in the name.

    Furthermore, just running the “show tables” query will not produce any output that you can see. SQL answers the query and then passes it to PHP, but you need to tell PHP to echo it to the page.

    Since it sounds like you’re very new to SQL, I’d recommend running the mysql client from the command line (or using phpmyadmin, if it’s installed on your system). That way you can see the results of various queries without having to go through PHP’s functions for sending queries and receiving results.

    If you have to use PHP, here’s a very simple demonstration. Try this code after connecting to your database:

    $result = mysql_query("show tables"); // run the query and assign the result to $result
    while($table = mysql_fetch_array($result)) { // go through each row that was returned in $result
        echo($table[0] . "<BR>");    // print the table that was returned on that row.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright. I have several queries <?php // Make a MySQL Connection mysql_connect(mm.hostname.net, user, pass)
Alright, currently I have my SWF hitting a php file that will go and
Alright, quick question. A server is running in Eastern Time. PHP program needs to
Alright. I have a query that looks like this: SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name`
Alright, so I have a query that looks like this: SELECT `orders`.*, GROUP_CONCAT( CONCAT(
Alright, so I'm new to Android programming, so far my experience has been quite
Alright, hoping someone can help. I've got a page used to search for employees.
Alright I'm pretty new to programming and stuff and I'm now trying to code
Alright when I do the code: <script type = text/javascript > document.write((new Date).getTime()); </script>
Alright, I'm extremely new to programming so odds are this is a really easy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.