• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
SQL Limit in PHP
 

SQL Limit in PHP

on

  • 1,443 views

 

Statistics

Views

Total Views
1,443
Views on SlideShare
1,443
Embed Views
0

Actions

Likes
0
Downloads
7
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    SQL Limit in PHP SQL Limit in PHP Document Transcript

    • SQL Limit in PHPIntroductionPHP has an operator named LIMIT. Using the LIMIT operator you can fetch a minimum andmaximum row from a database. In this article you will see, how to execute the LIMIToperator of MySQL in PHP.Suppose that there are ten rows in a table of any database in MySQL. You want to fetchonly five rows from your database; then you will use the LIMIT operator.Suppose there is the above table in your database. You want to fetch only five rows fromthis table. For this purpose you will use the LIMIT operator. An example of the LIMIToperator is as follows:Example 1. If you want to see only five rows from a table in MySQL then you will use thefollowing query: select * from emp limit 5Output www.vineetsaini.wordpress.com
    • Example 2. If you want to see only five rows from a table in PHP form, then you will usefollowing code.In this example, we have created a limit.php page, in which we execute a query with theLIMIT operator. In the LIMIT operator we put minimum and maximum limit of the tabledata. For example, the LIMIT 0,5 retrieves the row starting from row number 0 (the firstone) to a maximum of 5 rows.Code<html><title>Limit in PHP</title><body bgcolor="pink">< h3><u>SQL Limit in PHP<u></h3><center><?php $con = mysql_connect("localhost","root",""); if (!$con) { die( Could not connect: . mysql_error()); } mysql_select_db ("sunderdeep", $con); // sunderdeep is a database name $result = mysql_query ("select * from emp limit 0,5"); // emp is the table name indatabase echo " <table border=2 bgcolor =skyblue> <tr> <th align=center>emp_id</th> <th align=center>emp_Name</th> </tr>"; while ($row = mysql_fetch_array ($result)) { echo "<tr>"; echo "<td align=center>" . $row [emp_id] . "</td>"; echo "<td align=center>" . $row [emp_name] . "</td>"; echo "</tr>"; }echo "</table>"; mysql_close ($con);?></center> www.vineetsaini.wordpress.com
    • </body></html>The above file is saved with the name limit.php.OutputWhen you browse your limit.php file then you will get the following output:ConclusionSo in this article you saw, how to execute the LIMIT operator of MySQL in PHP. Using thisarticle one can easily understand how to execute the LIMIT operator of MySQL in PHP. www.vineetsaini.wordpress.com