$Link = msql_connect("msql.clearink.com");
msql_select_db("store", $Link);
$Query = "SELECT * FROM item i, SKU s ";
$Query .= "WHERE i.SKU = s.ID ";
$Result = msql_query($Query, $Link);
// get description of each field
while($Field = msql_fetch_field($Result))
{
print("Name: ". $Field->name. "
\n");
print("Table: ". $Field->table. "
\n");
print("Not Null: ". $Field->not_null. "
\n");
print("Primary Key: ". $Field->primary_key"
\n");
print("Unique: ". $Field->unique. "
\n");
print("Type: ". $Field->type. "
\n
\n");
}
msql_close($Link);
?>
Table 13.6. Properties of msql_fetch_field Object
Property Description
name (^) Name of the column
not_null (^) TRUE if the column cannot be null
primary_key (^) TRUE if the column is a primary key
table (^) Name of the table the column is from
type (^) Datatype of the column
unique (^) TRUE if the column is a unique key
object msql_fetch_object(integer result)
The msql_fetch_object function returns an object with a property for each column of
the resulting row. Each call to msql_fetch_object gets the next row from the results, or
returns FALSE when there are none left.
<?
$Link = msql_connect("msql.clearink.com");
msql_select_db("store", $Link);
$Query = "SELECT * FROM item";
$Result = msql_query($Query, $Link);
while($Row = msql_fetch_object($Result))
{
print("$Row->ID: $Row->Name
\n");
}
msql_close($Link);
?>