Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Member Anant's Avatar
    Join Date
    Feb 2005
    Location
    Indore , India
    Posts
    50
    Member #
    9049
    hi...

    i have been working on a project and for that i made a table :
    mysql_query("CREATE TABLE coun_dir(
    id INT NOT NULL AUTO_INCREMENT,
    PRIMARY KEY(id),
    Name VARCHAR(100),
    Roll_no VARCHAR(20),
    Rank VARCHAR(50),
    category VARCHAR(50),
    sub_cat VARCHAR(20),
    course VARCHAR(50))")
    or die(mysql_error());

    table is created ...and with the help of html and php forms ..i am inserting values in it also ...

    now the problem is that in category there are 3 values 1. engg 2.system 3. prog
    and for each of these values i have 2 values in sub_cat 1.fresher 2. exper

    now i have a requirement of only 3 people have category system and sub_cat of prog.
    what i want is that as soon as my database get these three peoples ..it should post a message saying that no other entry can be made to this fields ....

    how can i do this
    pls help
    Anant

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    I think this query should do it:
    "SELECT id FROM coun_dir WHERE category = 'system' AND sub_cat = 'prog'"
    Once you execute this, you can use mysql_num_rows on the result of the query to find how many exist like that.

  4. #3
    Member Anant's Avatar
    Join Date
    Feb 2005
    Location
    Indore , India
    Posts
    50
    Member #
    9049
    Quote Originally Posted by Shadowfiend
    I think this query should do it:
    "SELECT id FROM coun_dir WHERE category = 'system' AND sub_cat = 'prog'"
    Once you execute this, you can use mysql_num_rows on the result of the query to find how many exist like that.
    i will get the number ..but how to restrict the user from entering more data ....thats the main problem...

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Run the query, then say:
    PHP Code:
    if ( mysql_num_rows$rs ) > )
    {
        
    // output error
        
    exit;
    }
    else
    {
        
    // other output and insert code...


  6. #5
    Member Anant's Avatar
    Join Date
    Feb 2005
    Location
    Indore , India
    Posts
    50
    Member #
    9049
    Quote Originally Posted by Shadowfiend
    Run the query, then say:
    PHP Code:
    if ( mysql_num_rows$rs ) > )
    {
        
    // output error
        
    exit;
    }
    else
    {
        
    // other output and insert code...

    sorry its not working

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Can you post and/or attach your full code?

  8. #7
    Member Anant's Avatar
    Join Date
    Feb 2005
    Location
    Indore , India
    Posts
    50
    Member #
    9049
    Quote Originally Posted by Shadowfiend
    Can you post and/or attach your full code?

    here the code is :
    <?php
    include'config.php';
    include'opendb.php':


    $sql = "SELECT count(*) AS num_rows FROM coun_dir where Category='OBC' AND sub_cat='F' AND course='M.Tech.'";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    echo "<font size=4 color=black font=verdana>";
    echo $row['num_rows'];
    ?>

    well this gives me the number of people who are in category=obc , sub_cat=f and course=m.tech.

    but there are specific number of people allowed to take this combination....so when my database exceeds this number i want to prompt a message saying that seats are filled ...

    pls help me out its very important..

  9. #8
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Ah. So do this, after the `echo $row['num_rows'];':
    Code:
    if ( mysql_num_rows( $result ) > 3 )
        echo 'Seats are filled.';
    That should do it.

  10. #9
    Member Anant's Avatar
    Join Date
    Feb 2005
    Location
    Indore , India
    Posts
    50
    Member #
    9049
    Quote Originally Posted by Shadowfiend
    Ah. So do this, after the `echo $row['num_rows'];':
    Code:
    if ( mysql_num_rows( $result ) > 3 )
        echo 'Seats are filled.';
    That should do it.
    thanx it helped a lot ..but how can i use javascript in this to pop a warning message ....

  11. #10
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    You want it to pop up as soon as the page loads?


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:04 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com