Learning Mysql



Download 4.24 Mb.
View original pdf
Page365/366
Date04.08.2023
Size4.24 Mb.
#61806
1   ...   358   359   360   361   362   363   364   365   366
Learning MySQL
\n";
// Finish the row print "\n";
}
?>
428 | Chapter 14:
PHP


// ... and printout each of the columns foreach($row as $data)
print "\t
{$data}

Artists







// Connect to the MySQL server if (!($connection = @ mysqli_connect("localhost", "root",
"the_mysql_root_password")))
die("Cannot connect");
if (!(mysqli_select_db($connection, "music")))
die("Couldn't select music database Run the query on the connection if (result = @ mysqli_query($connection, "SELECT * FROM artist")))
die("Couldn't run query Until there are no rows in the result set, fetch a row into the row array and while (row = @ mysqli_fetch_array($result, MYSQL_ASSOC))
{
// Start a table row
Accessing MySQL Using PHP | 431

print "
\n";
// ... and printout each of the columns foreach($row as $data)
print "\t\n";
// Finish the row print "\n";
}
?>
artist_idartist_name
{$data}


Artist name
Album name


print $_GET["album"];
?>

Artists






























468 | Chapter 14:
PHP



artist_idartist_name
1New Order
2Nick Cave & The Bad Seeds
3Miles Davis
4The Rolling Stones
5The Stone Roses
6Kylie Minogue

Jack and Jill's Wedding Gift Registry


(if you've not logged in before, makeup a username and password)

Please enter a username
Please enter a password


// Show a logout link and a link to the main page echo "Logout | Gift list";
echo "\n

Gift editing page

";
// Show the existing gifts for editing showgiftsforedit($connection);
?>
Listing Gifts for Selection | 497


// Show a logout link echo "Logout Check whether the user is Jack or Jill (username is 'jack' or 'jill'); if so, show a link to the gift editing page.
if($_SESSION['username']=="jack" || $_SESSION['username']=="jill")
echo " | Edit gifts Connect to the MySQL DBMS and use the wedding database -
// credentials are in the file db.php if(!($connection= @ mysqli_connect(
$DB_hostname, $DB_username, $DB_password, $DB_databasename)))
showerror($connection);
// Pre-process the message data for security if(count($_GET))
$message = clean($_GET["message"], 128);
// If there's a message to show, output it if (!empty($message))
echo "\n

".
urldecode($message)."

";
echo "\n

Here are some gift suggestions

";
// Show the gifts that are still unreserved showgifts($connection, SHOW_UNRESERVED_GIFTS);
echo "\n

Your Shopping List

";
// Show the gifts that have been reserved by this user showgifts($connection, SHOW_GIFTS_RESERVED_BY_THIS_USER);
?>
Hello, World!
This is very interesting!
Hello, World!
This is very interesting!
".
"
Download 4.24 Mb.

Share with your friends:
1   ...   358   359   360   361   362   363   364   365   366




The database is protected by copyright ©ininet.org 2024
send message

    Main page