views:

39

answers:

1

I am fetching the data using mysql_fetch_array like :

while($row = mysql_fetch_array($select))
{
$tables[] =$row;
}

Now i need this $tables array as one dimensional array only, so that i can use it in

if(in_array($val['table_name'],$tables))
        { 
           //Some Code
        }

to check for whether the $val['table_name'] is in the $tables or not.. As for now I am getting $tables array as

Array
(
    [0] => Array
        (
            [TABLE_NAME] => jos_audittrail
        )

    [1] => Array
        (
            [TABLE_NAME] => jos_banner
        )

    [2] => Array
        (
            [TABLE_NAME] => jos_bannerclient
        )
..
..
..
..
}

But I need the $tables is form of..

Array
(
    [0] => jos_audittrail
    [TABLE_NAME] => jos_audittrail


    [1] => jos_banner
    [TABLE_NAME] => jos_banner

    [2] => jos_bannerclient
    [TABLE_NAME] => jos_bannerclient
..
..
..
}

How can i get the above array after applying "while loop" to "$row"?

+1  A: 

To get the array as you want it, you can do:

$tables = array();
$i = 0;
while($row = mysql_fetch_array($select)) {
    $tables[$i++] =$row['TABLE_NAME'];
    $tables['TABLE_NAME'] =$row['TABLE_NAME'];
}
codaddict
Thanks It Worked... :)
OM The Eternity
But I Just removed the "$tables['TABLE_NAME'] =$row['TABLE_NAME'];" line..it was displayed in between the array..
OM The Eternity