Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning Colums from a Table 1

Status
Not open for further replies.

Sylv4n

Technical User
Feb 27, 2002
83
GB
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?
 
I see,
Thanks, All I needed was this line:

$fields = mysql_list_fields( $database, $tablename );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top