Current location: Hot Scripts Forums » Programming Languages » PHP » Show Tables


Show Tables

Reply
  #1 (permalink)  
Old 09-24-07, 07:37 PM
blinn_shade's Avatar
blinn_shade blinn_shade is offline
Aspiring Coder
 
Join Date: Aug 2007
Posts: 540
Thanks: 0
Thanked 0 Times in 0 Posts
Show Tables

hey,

I have this code:

PHP Code:



## SHOW TABLES

function show_tables(){
    global 
$table_show_array;
    
    echo 
'<select name="dbtable">';
    
    
$result mysql_query("SHOW TABLES FROM `".CONFIG_DB_NAME."`");
    while(
$row mysql_fetch_array($result)){
        
        if(
in_array($row[0], $table_show_array)){
        }else{
        
            
$result2 mysql_query("SELECT * FROM `".$row[0]."`");
            
$num mysql_num_rows($result2);
            
            echo 
'<option value="'.$row[0].'">'.$row[0].' ( '.$num.' )</option>';
        }
    }
    
    echo 
'</select>';

It did once put all the tables in a drop down but now it has just stopped working. Does anyone know another to do this?

Thanks.
Reply With Quote
  #2 (permalink)  
Old 09-24-07, 08:22 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
When you say "just stopped working", does it show anything at all? Is the dropdown completely blank or does it have any values at all in it? Are you seeing any error messages?
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
  #3 (permalink)  
Old 09-24-07, 08:44 PM
blinn_shade's Avatar
blinn_shade blinn_shade is offline
Aspiring Coder
 
Join Date: Aug 2007
Posts: 540
Thanks: 0
Thanked 0 Times in 0 Posts
This is what I see. Just blank values.
Attached Images
File Type: jpg ss.jpg (4.4 KB, 125 views)
Reply With Quote
  #4 (permalink)  
Old 09-25-07, 08:12 AM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
When it was working did it use the parentheses that are showing in the image there? If not, I'd say that's a clue. If it just suddenly stopped working, something changed....was any code altered around the same time or anything else done?

It looks to me like the variable $num is not being filled or evaluated, and what's left are just the parentheses that surround it.

Try this....instead of this line:

echo '<option value="'.$row[0].'">'.$row[0].' ( '.$num.' )</option>';

...use this line and tell me if there's any difference:

print "<option value=\"$row[0]\">$row[0] ($num)</option>";

Finally, if you view the source of the dropdown in the page, does it show any values in the 'option value=' sections?
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
  #5 (permalink)  
Old 09-25-07, 08:39 AM
frosty1433 frosty1433 is offline
Newbie Coder
 
Join Date: Sep 2007
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
try this:
error_reporting(E_ALL);
Reply With Quote
  #6 (permalink)  
Old 09-25-07, 08:43 AM
aycintl aycintl is offline
Newbie Coder
 
Join Date: Sep 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
your code looks good. maybe there were a changes made in your database, specially the column name or table name.

try comparing your code from your database. maybe the column name is not "0" but maybe its something else like $row['column_name']
Reply With Quote
  #7 (permalink)  
Old 09-25-07, 07:41 PM
blinn_shade's Avatar
blinn_shade blinn_shade is offline
Aspiring Coder
 
Join Date: Aug 2007
Posts: 540
Thanks: 0
Thanked 0 Times in 0 Posts
None of the above worked. Still the same. I am wondering if it is something to do with the mysql privileges because my tables in there are all empty, I think I deleted them.

I have easyPHP installed on my machine, can anyone export the data from the database : information_schema and the table : USER_PRIVILEGES.

Thanks.
Reply With Quote
  #8 (permalink)  
Old 09-25-07, 08:22 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by blinn_shade View Post
my tables in there are all empty, I think I deleted them.
Umm, yeah, that could do it.

Quote:
Originally Posted by blinn_shade View Post
I have easyPHP installed on my machine, can anyone export the data from the database : information_schema and the table : USER_PRIVILEGES.
Are you asking someone here to login to your system and try an export??
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
  #9 (permalink)  
Old 09-25-07, 08:40 PM
blinn_shade's Avatar
blinn_shade blinn_shade is offline
Aspiring Coder
 
Join Date: Aug 2007
Posts: 540
Thanks: 0
Thanked 0 Times in 0 Posts
No.
I am asking if anyone would paste the SQL so I can import it.
Reply With Quote
  #10 (permalink)  
Old 09-25-07, 09:09 PM
blinn_shade's Avatar
blinn_shade blinn_shade is offline
Aspiring Coder
 
Join Date: Aug 2007
Posts: 540
Thanks: 0
Thanked 0 Times in 0 Posts
Ok I fixed it. Here is how I done it:

I used a foreach loop on the $row varible.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
updating database tables when tables may or may not have changed? Tim Mousel PHP 0 05-21-06 05:25 PM
borders dont show in firefox (tables) Bazzio CSS 5 09-05-05 03:43 PM
REQUEST: Tutorial or prmg on mysql/php/related tables chippewapublishing Script Requests 0 08-05-05 01:50 PM
Show DB records on tables 2 per row Avni_y ASP 1 07-14-05 07:49 AM
how to show mysql tables..... Merovingian PHP 2 02-04-04 05:06 PM


All times are GMT -5. The time now is 06:11 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.