Home Tutorial Php Sql Php Sql Rows

 
 

Share on Google+Share on Google+
Php Sql Rows
Posted on: December 10, 2010 at 12:00 AM
Advertisement
This example illustrates how to fetch row of database table.

Php Sql Rows

 This example illustrates how to fetch row of database table.

In this example we create mysql query to select the column name email which id has 12 and fetched row value and display it on the browser.

 

 

Table: users

 

Source Code of sql_rows.php 

<?php
  $con = mysql_connect("localhost","root","root");
  if (!$con){
    die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("test", $con);

  $result = mysql_query("SELECT id,email FROM users WHERE id = '12'");

  if (!$result) {
    echo 'Could not run query: ' . mysql_error();
    exit;
  }

  $row = mysql_fetch_row($result);
  echo "<b>ID: </b>";
  echo $row[0]."<br>";
  echo "<b>Email: </b>";
  echo $row[1];
?>

Download Source Code

 

Output:

Advertisement

Related Tags for Php Sql Rows:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 10, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com