TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-28-2010, 06:37 PM   #1 (permalink)
The Wanderer
 
unitechy's Avatar
 
Join Date: Mar 2008
Location: navi mumbai
Posts: 10
Thanks: 4
unitechy is on a distinguished road
Default Display mysql tables

Hello ninja programmers,

I have a database called "database" with tables:
table1
table2
table3
table4
table5

Now I want to display say only table1,2,3 in my sidebar. Say like in wordpress dashboard, where it displays post, categories, etc.
But I dont want to display all of the tables. How do I achieve that?

Thanks for your help.
__________________
How to crash your pc??
Send a message via AIM to unitechy Send a message via MSN to unitechy Send a message via Yahoo to unitechy Send a message via Skype™ to unitechy
unitechy is offline  
Reply With Quote
Old 02-28-2010, 06:57 PM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Interesting naming conventions. I would have reversed it, and called my database "table" and my tables "database#", but I'm cRAzEe.

How far have you gotten? If you're running this in WordPress, you can instantiate a new WPDB object to handle the database connection. After that it's just a matter of your query and method of displaying the results.
delayedinsanity is offline  
Reply With Quote
Old 02-28-2010, 07:39 PM   #3 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Quote:
Originally Posted by unitechy
My project is not related to wordpress, Wordpress was supposed to be an example. AFAIK
Code:
SHOW TABLES FROM `database_name`
displays the tables? But can I use WHERE clause in it? If yes how?
I hope you don't mind me cross posting this back into the forums, but it's useful for others to see the problem and possible solutions.

You can use a WHERE clause in a show tables statement, however you may be more interested in LIKE, ie
mysql Code:
SHOW TABLES FROM `database` LIKE 'table%'

However this will just display a list of the table names, and with your naming conventions, will actually list all of them. You may want to consider using the information_schema database for this;
mysql Code:
USE information_schema;
SELECT TABLE_NAME FROM `tables` WHERE SUBSTR(TABLE_NAME, -1) < 4;
delayedinsanity is offline  
Reply With Quote
The Following User Says Thank You to delayedinsanity For This Useful Post:
unitechy (02-28-2010)
Old 02-28-2010, 07:42 PM   #4 (permalink)
The Wanderer
 
unitechy's Avatar
 
Join Date: Mar 2008
Location: navi mumbai
Posts: 10
Thanks: 4
unitechy is on a distinguished road
Default

Brilliant. Much thanks :)
__________________
How to crash your pc??
Send a message via AIM to unitechy Send a message via MSN to unitechy Send a message via Yahoo to unitechy Send a message via Skype™ to unitechy
unitechy is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete records from multiple tables? (PHP, MySQL) shoaibmunir General 4 07-15-2009 09:30 PM
Search query multiple tables? (PHP, MySQL) shoaibmunir General 6 06-16-2009 01:47 PM
Menu Display Problem in IE6+ obolus XHTML, HTML, CSS 14 03-01-2008 07:57 PM
Error in connecting to MySQL via PHP EyeDentify MySQL & Databases 0 01-03-2008 01:06 PM
HTML Tables to MySQL database zeromancer General 0 05-08-2005 01:29 AM


All times are GMT. The time now is 07:35 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design