406 | Chapter 13: Web Database Applications
// ... and printout each of the columns foreach($row as $data) print "\t | {$data} | \n"; // Finish the row print "\n"; } ?>
Step
|
Variable Value
|
---|
// Set initial value for the variable $Variable=110; // Display the initial variable value. echo "
Initial value |
$Variable |
"; // Pass the variable by value to the AddNineteen_value() function. AddNineteen_value($Variable); // Display the variable value after passing it by value. echo "
After passing by value |
$Variable |
"; // Pass the variable by reference to the AddNineteen_reference() function. AddNineteen_reference($Variable); // Display the variable value after passing it by reference. echo "
After passing by reference |
$Variable |
"; // Function to add 19 to the received variable the function receives the variable value. function AddNineteen_value($MyVariable) { $MyVariable+=19; Language Basics | 425
} // Function to add 19 to the received variable the function receives a reference to the variable (note the ampersand before the variable name). function AddNineteen_reference(&$MyVariable) { $MyVariable+=19; } ?>
Artists
artist_id |
artist_name |
---|
// Connect to the MySQL server if (!($connection = @ mysql_connect("localhost", "root", "the_mysql_root_password"))) die("Cannot connect"); if (!(mysql_select_db("music", $connection))) die("Couldn't select music database Run the query on the connection if (result = @ mysql_query("SELECT * FROM artist", $connection))) die("Couldn't run query Until there are no rows in the result set, fetch a row into the row array and while (row = @ mysql_fetch_array($result, MYSQL_ASSOC)) { // Start a table row print "\n";
Share with your friends: |