Techno World Inc - The Best Technical Encyclopedia Online!

THE TECHNO CLUB [ TECHNOWORLDINC.COM ] => PHP => Topic started by: Hellraiser on August 29, 2007, 10:51:16 AM



Title: PHP: Lock or restrict MySQL table rows
Post by: Hellraiser on August 29, 2007, 10:51:16 AM
Lock or restrict MySQL table rows


To restrict entries in a table do the following:

$license=50;
$res=mysql_query("select * from employee") or die(mysql_error());
$totalrecords=mysql_num_rows($res);
if($totalrecords<=$license)
{  echo "Write code to add entries in the table";} else {echo "Sorry, your license does not permit more than $license entries";}

Explanation
Define the max entries allowed    $license=50;
Open the table    $res=mysql_query("select * from employee") or die(mysql_error());
Check the total entries    $totalrecords=mysql_num_rows($res);
If entries are more than or equal to allowed entries than add entries else do not add entries    if($totalrecords<=$license)
{  echo "Write code to add entries in the table";} else {echo "Sorry, your license does not permit more than $license entries";}