SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Can somebody help me?
    I want to fill a dropdown menu with all the table names in a database using PHP. Any help is greatly Appreciated.

    Thank you

    Sang N.


  2. #2
    SitePoint Addict Chris Roane's Avatar
    Join Date
    Jul 1999
    Location
    Helena, MT
    Posts
    287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure how to do what you are wanting to do, but i am pretty sure you are going to need to use this function:

    mysql_list_tables($database_name);

    Chris Roane

  3. #3
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is help for a Vietnamese fella!
    Get an array that has table names as values
    Do a loop, each loop generate sthing like:

    <option>$names[$index]</option>

    Is that good enough?
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?
    $db = mysql_connect("localhost", "user", "pass");
    $result = mysql_list_tables("dbname");
    print '<select name="tables">';
    for($i=0;$i<mysql_num_rows($result);$i++) {
    $tmp = mysql_tablename($result, $i);
    printf('<option value="%s">%s', $tmp, $tmp);
    }
    print '</select>';
    ?>


    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys
    Sang N.
    -------------------------------
    Send an E-card today!
    http://ecard.vinasite.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •