Product Documentation

FairCom SQL for PHP

Previous Topic

Next Topic

FairCom DB PHP Example


<?php

/* Connecting, selecting database */

$ses = ctsql_connect("ctreeSQL","ADMIN","ADMIN")

or die("Could not successfully connect to FairCom DB SQL: " . ctsql_error());

echo "Successfully connected to FairCom DB SQL!";


/* Performing SQL query */

$query = "SELECT * FROM my_table";

$result = ctsql_query($query) or die("Query failed : " . ctsql_error());


/* Printing results in HTML */

echo "<table>\n";

while ($line = ctsql_fetch_assoc($result)) {

echo "\t<tr>\n";

foreach ($line as $col_value) {

echo "\t\t<td>$col_value</td>\n";

}

echo "\t</tr>\n";

}

echo "</table>\n";


/* Free resultset */

ctsql_free_result($result);


/* Closing connection */

ctsql_close($ses);

?>

TOCIndex