I’m trying to populate an array with:
Column Name
Column Data Type
Next Column
Previous Column
From a mysql database.
I have:
[code=php]
<?php
mysql_connect(“host”,”username”,”pass”) ;
mysql_select_db(“db”) ;
$result = mysql_query(“SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = ‘test'”) ;
$result_set = array() ;
while ($array = mysql_fetch_assoc($result))
{
$result_set[] = array(‘COLUMN_NAME’=>$array[‘COLUMN_NAME’],’DATA_TYPE’=>$array[‘DATA_TYPE’], ‘PREV_COLUMN’=>$temp, ‘NEXT_COLUMN’=>’?????’) ;
$temp = $array[‘COLUMN_NAME’] ;
}
print_r($result_set) ;
?>
the column name and data type were no problem, i got the previous column by storing the column name in a temp variable and adding it in the next loop.
problem is i can’t get the next column.
I don’t use arrays very much, and i’m sure there is a much better method than this. can anyone help me out.