Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1613 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

need some help - froms from mysql db

Thread title: need some help - froms from mysql db
Closed Thread  
Page 1 of 4 1 2 3 4 >
    Thread tools Search this thread Display Modes  
09-05-2007, 03:53 PM
#1
pixelgod is offline pixelgod
Status: Member
Join date: Jul 2007
Location: 127.0.0.1
Expertise:
Software:
 
Posts: 110
iTrader: 4 / 100%
 

pixelgod is on a distinguished road

Send a message via MSN to pixelgod

  Old  need some help - froms from mysql db

Hey TFL,
I need a little help,
I want a drop down to take it's options from a MySQL database. Sounds easy, but what I need is for it to set every table with the beginning prefix CMS_, and I don't want the CMS_ to show up on the drop down, only the text after it.

Thanks in advance!

09-05-2007, 05:12 PM
#2
Haris is offline Haris
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
 
Posts: 2,741
iTrader: 9 / 100%
 

Haris is on a distinguished road

  Old

You want to show table names OR data in those tables?

09-05-2007, 05:25 PM
#3
pixelgod is offline pixelgod
Status: Member
Join date: Jul 2007
Location: 127.0.0.1
Expertise:
Software:
 
Posts: 110
iTrader: 4 / 100%
 

pixelgod is on a distinguished road

Send a message via MSN to pixelgod

  Old

The table names

EDIT: this is what I have, I just need it to filter out the ones without CMS_ in front.

$result = mysql_list_tables(dbname);
if(mysql_num_rows($result)) {
while($row = mysql_fetch_array($result))
{
echo"<option value=\"$row[0]\">$row[0] $row[category]</option>";
}
}

09-05-2007, 06:56 PM
#4
Wildhoney is offline Wildhoney
Wildhoney's Avatar
Status: Request a custom title
Join date: Feb 2006
Location: Nottingham
Expertise:
Software:
 
Posts: 1,648
iTrader: 18 / 95%
 

Wildhoney is on a distinguished road

Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney

  Old

PHP Code:
<?php

    $szTableName 
'cms_members';
    echo 
preg_replace('/^cms_/i'''$szTableName);

?>

09-05-2007, 07:44 PM
#5
pixelgod is offline pixelgod
Status: Member
Join date: Jul 2007
Location: 127.0.0.1
Expertise:
Software:
 
Posts: 110
iTrader: 4 / 100%
 

pixelgod is on a distinguished road

Send a message via MSN to pixelgod

  Old

Uh, I need something, that will only display the names of the tables in the database with CMS_ in front of it.

09-05-2007, 07:45 PM
#6
Wildhoney is offline Wildhoney
Wildhoney's Avatar
Status: Request a custom title
Join date: Feb 2006
Location: Nottingham
Expertise:
Software:
 
Posts: 1,648
iTrader: 18 / 95%
 

Wildhoney is on a distinguished road

Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney

  Old

Your description is too vague and too equivocal.

09-05-2007, 07:51 PM
#7
pixelgod is offline pixelgod
Status: Member
Join date: Jul 2007
Location: 127.0.0.1
Expertise:
Software:
 
Posts: 110
iTrader: 4 / 100%
 

pixelgod is on a distinguished road

Send a message via MSN to pixelgod

  Old

Okay, lets say I have a MySQL database with these tables
CMS_coolbeans
CMS_talkfreelance
Wildhoney
Pixelgod
I need a small script, that will put the names of the tables with CMS_ in front of them into a dropdown. So it would display: CMS_coolbeans and CMS_talkfreelance but NOT Wildhoney and Pixelgod. The reason I need a script is because my script will be adding and deleting tables often. If possible I would also like the CMS_ to be removed when it displays them in a drop down. I don't need it to interact with the content inside the tables at all.

09-05-2007, 08:15 PM
#8
Wildhoney is offline Wildhoney
Wildhoney's Avatar
Status: Request a custom title
Join date: Feb 2006
Location: Nottingham
Expertise:
Software:
 
Posts: 1,648
iTrader: 18 / 95%
 

Wildhoney is on a distinguished road

Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney

  Old

PHP Code:
<?php

    $aTables 
= array(    'cms_members',
                        
'cms_coolbeans',
                        
'cms_talkfreelance',
                        
'Wildhoney',
                        
'PixelGod');
                        
    foreach(
$aTables as $szTableName)
    {
        if(
substr($szTableName04) != 'cms_')
        {
            continue;
        }
        
        echo 
preg_replace('/^cms_/i'''$szTableName) . '<br />';
    }

?>
My simple example so you can see. I'm sure you can apply that to your scenario.

09-05-2007, 08:47 PM
#9
pixelgod is offline pixelgod
Status: Member
Join date: Jul 2007
Location: 127.0.0.1
Expertise:
Software:
 
Posts: 110
iTrader: 4 / 100%
 

pixelgod is on a distinguished road

Send a message via MSN to pixelgod

  Old

Hmm, I can't seem to change the array to mysql_list_tables(clanname) all I get are errors. Will this code work with MySQL?

09-05-2007, 08:49 PM
#10
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

Be advised that mysql_list_tables has been depreciated since php4, I wouldn't count on it being in php6 when it comes out

Closed Thread  
Page 1 of 4 1 2 3 4 >


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

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed