I am trying to make a reusable bit of code that can (regardless of how many cols there are) make a table in HTML from a databas, What I have so far:
$server = "server";
$username = "user1";
$password = "pass1";
$database = "database";
$tablename = "Charts";
$query = "select * from $tablename";
//connect to the database and run relevent query
mysql_connect( $server, $username, $password ) OR die(' ** Unable to connect: '.mysql_error());
mysql_select_db( $database ) OR die(' ** Unable to select database: '.mysql_error());
$result = mysql_query( $query ) OR die (' ** Query error: '.mysql_error());
//Get the number of results returned
$howManyRows = mysql_num_rows($result);
okay now this all works fine, what I cant figure out is how to use the:
$fields = mysql_list_fields( $result );
not 100% sure that is the correct syntax but dont know where to check it.
I get the error
'Warning: Wrong parameter count for mysql_list_fields() in MY_PHP_URL on line 44'
am I going about this in the right way?
$server = "server";
$username = "user1";
$password = "pass1";
$database = "database";
$tablename = "Charts";
$query = "select * from $tablename";
//connect to the database and run relevent query
mysql_connect( $server, $username, $password ) OR die(' ** Unable to connect: '.mysql_error());
mysql_select_db( $database ) OR die(' ** Unable to select database: '.mysql_error());
$result = mysql_query( $query ) OR die (' ** Query error: '.mysql_error());
//Get the number of results returned
$howManyRows = mysql_num_rows($result);
okay now this all works fine, what I cant figure out is how to use the:
$fields = mysql_list_fields( $result );
not 100% sure that is the correct syntax but dont know where to check it.
I get the error
'Warning: Wrong parameter count for mysql_list_fields() in MY_PHP_URL on line 44'
am I going about this in the right way?