Beruflich Dokumente
Kultur Dokumente
MySQL Database
Planning
MySQL Hostname:
Let the database name be:
MySQL Username:
MySQL Password:
localhost
gjimt
gjimt
gjimt123
reg_users
PHP Script
<?php
echo "<br>This is excellent!";
echo "<br>Let us try: database connection, selection, query and fenth data row
from database.";
//1. Define Variables
$hostname
= "localhost";
$user_name = "gjimt";
$password
= "gjimt123";
$database_name = "gjimt" ;
$table_name = "reg_users";
//2. Make a MySQL Connection
mysql_connect( $hostname, $user_name, $password) or die(mysql_error());
//3. Select Database
mysql_select_db($database_name) or die(mysql_error());
//4. Retrieve all the data from the "reg_users" table
$sql_query_string = "SELECT * FROM $table_name" ;
$result = mysql_query($sql_query_string) or die(mysql_error());
//5. store the record of the "reg_users" table into $row and display
//$row = mysql_fetch_array( $result );
while ($row = mysql_fetch_array( $result ) ) {
//6. Print out the contents of the entry
echo "<br>Name: ".$row['user_name'];
echo ", Email: ".$row['user_email'];
}
?>