Professional Web Applications Themes

Can't get SHOW TABLES to work ! - MySQL

Hi, I'm using PHP, MYSQL My code - - - $donor_db = "donor_database"; $new_db = "new_database"; $db_conn = mysql_connect($host, $user, $pass); //get a list of all tables in the donor database mysql_select_db($donor_db, $db_conn); $query2 = "Show tables from ".$donor_db; $result2 = mysql_query($query2); $array2 = mysql_fetch_array($result2); //there are 40 tables in the donor database My Problem 1 --- foreach ($array2 as $table_name) { echo $table_name."<br>"; } //in the browser this returns the first table listed twice - - // //accounts //accounts My problem 2 - - - while ($array2 = mysql_fetch_row($result2)) { echo $array2[0]."<br>"; } //in the browser this returns 39 ...

  1. #1

    Default Can't get SHOW TABLES to work !

    Hi,

    I'm using PHP, MYSQL

    My code - - -

    $donor_db = "donor_database";
    $new_db = "new_database";
    $db_conn = mysql_connect($host, $user, $pass);

    //get a list of all tables in the donor database
    mysql_select_db($donor_db, $db_conn);
    $query2 = "Show tables from ".$donor_db;
    $result2 = mysql_query($query2);
    $array2 = mysql_fetch_array($result2);

    //there are 40 tables in the donor database

    My Problem 1 ---
    foreach ($array2 as $table_name)
    {
    echo $table_name."<br>";
    }

    //in the browser this returns the first table listed twice - -
    //
    //accounts
    //accounts


    My problem 2 - - -

    while ($array2 = mysql_fetch_row($result2))
    {
    echo $array2[0]."<br>";
    }

    //in the browser this returns 39 table names excluding the first one
    (accounts)

    TIA - Any help much appreciated

    Robbo Guest

  2. #2

    Default Re: Can't get SHOW TABLES to work !

    == Quote from Robbo (com)'s article 

    this is a PHP problem!
    --
    POST BY: lark with PHP News Reader
    lark Guest

  3. #3

    Default Re: Can't get SHOW TABLES to work !

    On Jul 16, 4:52 pm, lark <net> wrote: 
    >
    > this is a PHP problem!
    > --
    > POST BY: lark with PHP News Reader- Hide quoted text -
    >
    > - Show quoted text -[/ref]



    Great, they - the PHP group tell me it's a Mysql problem - which is
    why I posted here !

    Thanks anyway


    Robbo Guest

  4. #4

    Default Re: Can't get SHOW TABLES to work !

    On Mon, 16 Jul 2007 21:24:33 +0200, Robbo <com> wrote: 
    >
    > Great, they - the PHP group tell me it's a Mysql problem - which is
    > why I posted here ![/ref]

    Indeed just a PHP-issue. Answered in comp.lang.php
    --
    Rik Wasmus
    Rik Guest

  5. #5

    Default Re: Can't get SHOW TABLES to work !

    Am 16.07.2007, 12:08 Uhr, schrieb Robbo <com>:
     

    Concerning problem 2: If you execute both problematic parts in one script,
    the first mysql_fetch_row has already fetched the first row from the
    result resource, which is "accounts". It cannot turn up in the second loop
    unless you use my_sql_data_seek to reposition the index for array2 before.
    I am still a beginner, so I can't tell about problem 1.

    --
    P.A. Guest

  6. #6

    Default Re: Can't get SHOW TABLES to work !

    Am 16.07.2007, 12:08 Uhr, schrieb Robbo <com>:
     

    Concerning problem 2: If you execute both problematic parts in one script,
    the first mysql_fetch_row has already fetched the first row from the
    result resource, which is "accounts". It cannot turn up in the second loop
    unless you use my_sql_data_seek to reposition the index for array2 before.
    I am still a beginner, so I can't tell about problem 1.

    --
    --
    Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/
    P.A. Guest

Similar Threads

  1. Tables don't show in Design View
    By pwalters in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: January 23rd, 05:00 PM
  2. ASP.net-Tables will not show from Access 2003 DB
    By Colleen89 in forum Dreamweaver AppDev
    Replies: 4
    Last Post: August 10th, 07:33 AM
  3. No tables show up under databases/connections
    By Sunder27 in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 1
    Last Post: March 24th, 03:52 AM
  4. Problem with Show tables; :(
    By Adrian Majchrzak in forum PHP Development
    Replies: 2
    Last Post: January 14th, 10:35 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139