Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
|
|
Mysql/php _list_tables question |
Page: 1 | Reply |
Sep 14th 2002 | #69183 Report |
Member since: Mar 16th 2001 Posts: 2421 |
I would like to extract just one table from the database. Here is the code I am using. Works but it pulls out every single table I have. Is there a way to just pull out one specified table? [php] function ddtables ($dbname){ if (!empty($dbname)) { $result = mysql_list_tables($dbname); $i = 0; echo "\nTables: onChange=\"JavaScript:form.submit();\">\n"; echo "\n"; while ($i < mysql_num_rows ($result)) { $tb_names[$i] = mysql_tablename ($result, $i); echo "\n"; $i++; } echo ""; } } [/php] |
Reply with Quote Reply |
Sep 14th 2002 | #69253 Report |
Member since: Jun 30th 2001 Posts: 447 |
Let me get this straight: You want to create a drop down list of all the tables in your mySQL database? If so, that code will work. I'm a little confused.
|
Reply with Quote Reply |
Sep 15th 2002 | #69317 Report |
Member since: Mar 16th 2001 Posts: 2421 |
No, it's a drop down right now with all of them. What I would like is just "one" specified table to show up in the drop down... Yes, everything does work right now. I just want to change it to limit access to only one table. Right now all 25 or so show up and I only need to view one in the drop down. |
Reply with Quote Reply |
Sep 15th 2002 | #69326 Report |
Member since: Jun 30th 2001 Posts: 447 |
Well, the easiest way would be to put an if statement inside the while loop. If $tb_names[$i] equals the name of the table you want to show, echo it; otherwise, add 1 to $i and go through the loop again. To save processing time after the table name has been echoed, put a break; inside the if statement. HTH!
|
Reply with Quote Reply |
Sep 15th 2002 | #69328 Report |
Member since: Mar 16th 2001 Posts: 2421 |
I'll try it out. Thanks. I thought there may be an actual Mysql command I was missing to display just one table like the list_tables function. |
Reply with Quote Reply |
Sep 16th 2002 | #69574 Report |
Member since: Jun 30th 2001 Posts: 447 |
Nope, don't think any function like that exists. The best way though is to loop up list_tables() in the PHP function reference at http://www.php.net and look for similar functions that it suggests in the left column. Very helpful at times.
|
Reply with Quote Reply |
Page: 1 | Back to top |
Please login or register above to post in this forum |
© Web Media Network Limited. All rights reserved. No part of this website may be reproduced without written permission. Photoshop is a registered trademark of Adobe Inc.. TeamPhotoshop.com is not associated in any way with Adobe, nor is an offical Photoshop website. |