selecting specific row(s) of a table using sql command

selecting specific row(s) of a table using sql command

selecting-specific-rows-of-a-table-using-sql-command.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>selecting specific row(s) of a table using sql command</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="Author" content="Md Iqbal Hosan">
  <meta name="title" content="selecting specific row(s) of a table using sql command">
  <meta name="keywords" content="php, example, code, table, sql command, sql, select specific rows of a table">
  <meta name="description" content="selecting specific row(s) of a table using sql command">
  <style>
   h2, h4{background:#eee; color:#000087;}
   h2{ padding:3px; margin:3px; font-size:22px;}
   h4{ padding:2px; margin:2px; font-size:19px;}
   p{padding:2px; margin:2px; color:#0099Fe;}
   body{ background:#FFFFFc;}
  </style>
 </head>
 <body>
  <h2>selecting specific row(s) of a table using sql command</h2>
  <pre>
   <?php
    /*
     ---------------------------------------------------------------------
     WE WANT TO SELECT ROWS WHOSE DepartmentID=3 BY USING SQL COMMAND
     ---------------------------------------------------------------------
    */
    $sql = "SELECT * FROM departments WHERE DepartmentID=3";
    /*
     --------------------------------------------------------------------------
     YOU CAN FILTER BY ANY COLUMN VALUES AS YOU WISH
     JUST HAVE TO MAKE SURE THE COLUMN IS EXIST AND IT IS USED IN WHERE CLAUSE
     SAY FILTER BY : DepartmentName
     --------------------------------------------------------------------------
    */
    $sql = "SELECT * FROM departments WHERE DepartmentName='Admin'";
    /*
     ----------------------------------------------------
     IN PHP YOU CAN DO THIS. 
     GET CONNECTION TO DATABASE BY USING : mysql_connect()
     SELECT DATABASE BY USING : mysql_select_db()
     THEN RUN THE QUERY
     ----------------------------------------------------
    */
    
    mysql_connect('localhost', 'root', 'root');
    mysql_select_db('hr');
    mysql_query($sql);
    
    /*
     -----------------------------------------------------------------------------
     TO RUN THE PHP CODE PROVIDE REAL DATA TO mysql_connect AND mysql_select_db()
     -----------------------------------------------------------------------------
    */
   ?>
  </pre>
 </body>
</html>

selecting specific row(s) of a table using sql command - output in the client

No comments:

Post a Comment

leave your comments here..