Variables
Coldfusion variables are set with
Coldfusion: myVar = 0>;
PHP: $myVar = 0>;
PHP: $myVar = 0>;
Differences between URL variables:
Coldfusion: #URL.myVar#
PHP: $_GET['myVar'];
PHP: $_GET['myVar'];
Differences between POST variables:
Coldfusion: #POST.myVar#
PHP: $_POST['myVar'];
PHP: $_POST['myVar'];
Execute a query

SELECT * FROM USER
If you use PHP, when you add a query, you have to include in your page all the parameters to connect to database. I suggest to read this post to have more info about this topic. A tipical query in PHP is structured in this way:
// Connection's Parameters
$db_host="localhost";
$db_name="database_name";
$username="database_username";
$password="database_password";
$db_con=mysql_connect($db_host,$username,$password);
$connection_string=mysql_select_db($db_name);
// Connection
mysql_connect($db_host,$username,$password);
mysql_select_db($db_name);
// Query
$sql = 'SELECT * FROM USER';
$getUser = mysql_query($sql);
?>
How you can see, I defined a variable $sql (with the query SQL code). mysql_query($sql) execute the query.
Query results
After the execution of a query you would show the query results. With coldfusion you ca use
#name#, #email#, #city#
You can also use this dotted code if inside a
#getUser.name#, #getUser.email#, #getCity.city#
With PHP you have use mysql_fetch_array() method inside a while statement:
while ($row = mysql_fetch_array($getUser)){
echo $row['name'] . ',' ;
echo $row['email'] . ',' ;
echo $row['city'] . ',' ;
}
?>
*best site for learn http://coldfusion-example.blogspot.com
0 comments:
Post a Comment