Hosting Services > Developer's Corner > MySQL Database

Using MySQL in PHP

The following code fragment illustrates the use of MySQL in PHP:

<?php

mysql_connect("localhost","username", "password");

$result = mysql_db_query("db_name","select * from table");

echo ""; while($row = mysql_fetch_row($result)) { echo ""; for ($i = 0; $i < count($row); $i++) { echo ""; } echo ""; } echo "

";

echo $row[$i];

echo "

";

mysql_free_result($result);

?>