int mysql_num_rows ( resource result ) : mysql_num_rows « MySQL Database « PHP

PHP
1. Chart
2. Class
3. Components
4. Cookie Session
5. Data Structure
6. Data Type
7. Date
8. Design Patterns
9. Development
10. DNS
11. Email
12. File Directory
13. Form
14. Functions
15. Graphics Image
16. HTML
17. Language Basics
18. Login Authentication
19. Math
20. MySQL Database
21. Network
22. Operator
23. PDF
24. Reflection
25. Statement
26. String
27. Utility Function
28. Web Services SOAP WSDL
29. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
PHP » MySQL Database » mysql_num_rows 
int mysql_num_rows ( resource result )
 
Building Queries on the Fly 

<?php 
function opendatabase ($host,$user,$pass) { 
    try 
        if ($db = mysql_connect ($host,$user,$pass)){ 
            return $db; 
        else 
            throw new exception ("Sorry, could not connect to mysql.")
        
    catch (exception $e) { 
        echo $e->getmessage ()
    

function selectdb ($whichdb, $db){ 
    try 
        if (!mysql_select_db ($whichdb,$db)){ 
            throw new exception ("Sorry, database could not be opened.")
        
    catch (exception $e) { 
        echo $e->getmessage()
    

function closedatabase ($db){ 
    mysql_close ($db)


$db = opendatabase ("localhost","root","")

selectdb ("mydatabase",$db)

$_POST['user'] "root"
$_POST['pass'] ""


function validatelogin ($user,$pass){ 
    mysql_real_escape_string ($user)
    mysql_real_escape_string ($pass)
    $thequery = "SELECT * FROM userlogin WHERE username='$user' AND password='$pass'"
    if ($aquery = mysql_query ($thequery)){ 
        if (mysql_num_rows ($aquery0){ 
            return true
        else 
            return false
        
    else 
        echo mysql_error()
    



if (validatelogin ($_POST['user'],$_POST['pass'])){ 
    echo "You have successfully logged in."
else 
    echo "Sorry, you have an incorrect username and/or password."


//Then close the database. 
closedatabase ($db)


?>
  
  
Related examples in the same category
1. Listing All Rows and Fields in a Table
2. Finding the Number of Rows Returned by a SELECT Statement with mysql_num_rows()
3. mysql_num_rows.php
4. function mysql_num_rows() determines the number of rows returned from a SELECT query statement.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.