|
Posted by Rich on 02/28/06 19:13
In article <op.s5npmbfh6v94lj@news.east.cox.net>, malcolm says...
>
>On Mon, 27 Feb 2006 17:29:51 -0500, J.O. Aho <user@example.net> wrote:
>
>> malcolm wrote:
>>> Hello All,
>>> On my rented space I have only one database. I have a few users at
>>> my site
>>> and any mysql tables I made for them have their initials as a prefix
>>> i.e.
>>> aa_phonelist, aa_addresses, aa_otherjunk
>>> bb_phonelist, bb_addresses, bb_otherjunk
>>> I want to make a drop down selection for the tables so that each can
>>> see his/her tables
>>> but ONLY theirs. What I really want is a query like 'Show tables where
>>> prefix like aa_'
>>> and send the results to the drop down. Obviously that won't work but
>>> I have wracked my
>>> small brain for quite some time now and can't seem to find something
>>> that will work.
>>> I have tried to use the show table results with things like in_array
>>> but I just can't
>>> make it work. This is on a logged-in page so I know the prefix but I
>>> can't seem to limit
>>> show tables at all and I can't find a way to strip out the other
>>> prefixes from the resulting
>>> array. Not zillions but quite a few tables and new ones all the time,
>>> so this needs to be
>>> dynamic.
>>
>> Look at the mysql_list_tables() function, if you aren't using mysql on
>> the host, then it will be more tricky. If you use the function, then you
>> will need to filter the result when you got it to PHP, while the
>> alternative options could work with WHERE statements.
>>
>> http://www.php.net/manual/en/function.mysql-list-tables.php
>>
>>
>> //Aho
>
>
>Thanks Aho but I'm able to list the tables ok and do the drop down but
>I can't figure how to filter the array returned by the 'show tables' query.
>That function does the same but I don't see any way there to filter the
>result. I'm looking at array_clean now, thanks for reply.
I'm not sure if you can add a "WHERE" clause to the "show databases" command. I
thought that was a command specific to MySQL and may not function like your
usual SQL commands (e.g. select, update, delete).
As an example if I were using PostgreSQL, I'd use a command like "\dt" to get
the list of tables back instead. The command is specific to that database and
isn't designed to add conditions on to it.
If you are able to get the full list with PHP though, you can capture that into
an array and filter through that list.
Rich
--
Newsguy BonusBytes! - Free monthly rewards
http://newsguy.com/bonusbytes.htm
Navigation:
[Reply to this message]
|