function mysql_result() produces a data set. : mysql_result « MySQL Database « PHP






function mysql_result() produces a data set.

 
Its syntax is: int mysql_result (int result_id, int row [, mixed field])

<?
@mysql_connect("localhost", "root","") or die("Could not connect to MySQL server!");
@mysql_select_db("mydatabase") or die("Could not select database!");
$query = "SELECT * FROM mytable";
$result = mysql_query($query);
$x = 0;
print "<table>";
print "<tr><th>ID</th><th>Title</th><th>MyValue</th></tr>";
while ($x < mysql_numrows($result)) :
     $id = mysql_result($result, $x, 'id');
     $name = mysql_result($result, $x, 'title');
     $price = mysql_result($result, $x, 'myvalue');
     print "<tr>";
     print "<td>$id</td><td>$title</td><td>$myvalue</td>";
     print "</tr>";
     $x++;
endwhile;
</table>
mysql_close();
?>
  
  








Related examples in the same category

1.mysql_result-2.php
2.mysql_result.php