|
|
|
|
Thread title: need some help - froms from mysql db |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
09-05-2007, 03:53 PM
|
#1
|
Status: Member
Join date: Jul 2007
Location: 127.0.0.1
Expertise:
Software:
Posts: 110
|
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
|
Status: Request a custom title
Join date: Dec 2005
Location:
Expertise:
Software:
Posts: 2,741
|
You want to show table names OR data in those tables?
|
|
09-05-2007, 05:25 PM
|
#3
|
Status: Member
Join date: Jul 2007
Location: 127.0.0.1
Expertise:
Software:
Posts: 110
|
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
|
Status: Request a custom title
Join date: Feb 2006
Location: Nottingham
Expertise:
Software:
Posts: 1,648
|
PHP Code:
<?php
$szTableName = 'cms_members'; echo preg_replace('/^cms_/i', '', $szTableName);
?>
|
|
09-05-2007, 07:44 PM
|
#5
|
Status: Member
Join date: Jul 2007
Location: 127.0.0.1
Expertise:
Software:
Posts: 110
|
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
|
Status: Request a custom title
Join date: Feb 2006
Location: Nottingham
Expertise:
Software:
Posts: 1,648
|
Your description is too vague and too equivocal.
|
|
09-05-2007, 07:51 PM
|
#7
|
Status: Member
Join date: Jul 2007
Location: 127.0.0.1
Expertise:
Software:
Posts: 110
|
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
|
Status: Request a custom title
Join date: Feb 2006
Location: Nottingham
Expertise:
Software:
Posts: 1,648
|
PHP Code:
<?php
$aTables = array( 'cms_members', 'cms_coolbeans', 'cms_talkfreelance', 'Wildhoney', 'PixelGod'); foreach($aTables as $szTableName) { if(substr($szTableName, 0, 4) != '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
|
Status: Member
Join date: Jul 2007
Location: 127.0.0.1
Expertise:
Software:
Posts: 110
|
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
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
Be advised that mysql_list_tables has been depreciated since php4, I wouldn't count on it being in php6 when it comes out
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
|
|