SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: row count

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile row count

    I have created a submitting form from where user input his name and his choice (eg. pen, pencil, notebook). he have to choose two item from this three item. But the matter is if a item is already choosen by 10 user so that item will not be inputting into database table and he will get a massege.

    any body help me please how will I set my logic a nd code.

  2. #2
    Web Developer stickycarrots's Avatar
    Join Date
    Jul 2005
    Location
    Illinois State University
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So you don't want the user to be able to use an item that's been used 10 times already?

    PHP Code:
    // creates the total variable //
    $itemthere mysql_query("SELECT COUNT(*) AS total FROM table WHERE name='$item'");
    $itemthere2 mysql_fetch_array($itemthere);
    $total $itemthere2['total'];

    // checks to see if it's below 10 //
    if ($total 10) {

    // do the action //

    } else {

    // show an error //


    I'm not 100% sure if that's what you're looking for, but it should work and it's a start


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •