?php / * Connecting, selecting database * / $link = mysql_connect( "mysql_host", "mysql_user", "mysql_password") or die("Could not connect"); print "Connected successfully"; mysql_select_db("my_database") or die("Could not select database"); / * Performing SQL query * / $query = "SELECT * FROM my_table"; $result = mysql_query($query) or die("Query failed"); / * Printing results in HTML * / print "table \n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {print "\t tr \n"; foreach ($line as $col_value) {print "\t\t td $col_value / td \n";} print "\t / tr \n";} print" / table \n"; / * Free resultset * / mysql_free_result($result); / * Closing connection * / mysql_close($link);?
?php $link = mysql_connect( "hote_mysql", "login_mysql", "mot_de_passe_mysql") or die ("Impossible de se connecter"); print ("Connexion réussie"); mysql_select_db ("ma_base") or die ("Impossible d'accéder à la base de données"); $query = "SELECT * FROM ma_table"; $result = mysql_query ($query) or die ("La requête a échoué"); / / Affichage du résultat au format HTML print "table \n"; while($line = mysql_fetch_array($result)) {print "\t tr \n"; while(list($col_name, $col_value) = each($line)) {print "\t\t td $col_value / td \n";} print "\t / tr \n";} print" / table \n"; mysql_close($link);?