Saturday, 21 May 2011

Learn PHP online : PHP day - 25


Php Mysql_fetch Functions Script Notes




Mysql_fetch_assoc: Function reads a record from result set and it returns as an associative array. Each element key is the name of the column.
Mysql_fetch_array: This function reads a record from result set and returns as numeric array and associative array elements.
Mysql_fetch_object: This function reads a record from result set and returns as an object. This object belongs to the std base class.
Php Mysql_fetch Functions Script:
<select>
<?php
mysql_connect("localhost","root","");
$dbs=mysql_list_dbs();
while ($db=mysql_fetch_row($dbs))
{
echo "<option> $db[0]</option>";
}
?>
</select>

Script 2

<select>
<?php
mysql_connect("localhost","root","");
$dbs=mysql_list_tables("information_schema");
while ($db=mysql_fetch_row($dbs))
{
echo "<option> $db[0]</option>";
}
?>
</select>

No comments:

Post a Comment

Visual comparison of the two methods, creating a simple table.

Option 1, using PHP: // PHP $html = '<table>' ;     foreach ( $data as $row ) {     $html .= '<tr>...