[need] availability check from stock

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [need] availability check from stock

    Hi,

    This thread is mostly related to my old thread (http://coding-talk.com/f14/%5Bneed%5...-search-18367/). After doing all this okay with the help of CreativityKills, now I'm stuck with with another issue. That is, when I have only one phone on the stock, two or more user put this phone on the cart at the same time and after that ordering the same phone could create a major issue for me as I've only one phone on the stock.

    Let me clear the issue elaborately:

    1. I've 1 Samsung S3 phone on my stock.
    2. Now putting the phone on the session by one user and he can order the phone easily.
    3. But if 2 or more users put the phone on their cart session could be a major problem for me.

    What I did in this circumstance: I checked the phone whether its available or not with the following code before the phone going on the cart.
    PHP Code:
        $q2=mysql_num_rows(mysql_query("SELECT available FROM phone_info WHERE id='$phid'"));
        if(
    $q2!=0)
        {
                 
    //putting the processing code
            
    }
    else{
    //redirecting with not available code

    but when someone put it on the cart and don't order it, it creates another mess. That is the phone remain unsold but showing the its not in the stock. because of this issue.

    now I've decided to check it while ordering the phone(s).
    Now here in this point I need assistance from you. I've one or more then one phone on the cart and I need to check whether its available or not and if its not available redirects with the one which isn't available. and if all are available then process the order.

    Can anybody help me with this please?

    #2
    Is there any one can help me please in this issue?

    Comment


      #3
      Can you have if the session is set then check on every page to see if it is still available?

      Comment


        #4
        Originally posted by something else View Post
        Can you have if the session is set then check on every page to see if it is still available?
        I don't understand. can you please elaborate?

        Comment


          #5
          I doubt that those two risks can be solved together, maybe you should decide which one to apply. It can be that the one on the ordering is best, simply because its is yours to sell the phone first, than maybe echo some "sorry message" with explanation that the item was just sold minutes ago, if you have some time stamp.
          <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

          Comment


            #6
            Originally posted by arnage View Post
            I doubt that those two risks can be solved together, maybe you should decide which one to apply. It can be that the one on the ordering is best, simply because its is yours to sell the phone first, than maybe echo some "sorry message" with explanation that the item was just sold minutes ago, if you have some time stamp.
            Yeah! Now can you just tell me how to show which book isn't available from a list with php please?

            Comment


              #7
              Just like you show in first post, if "available" table is what it seems it is.

              $quantity = mysql_num_rows(mysql_query("SELECT available FROM phone_info WHERE id='$phid'"));

              Or you meant all? In that case use while() to loop table for all items where is available 0.
              Last edited by arnage; 18.05.13, 10:10.
              <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

              Comment


                #8
                Hello my friend i have another method which i used
                $sql=mysql_query("SELECT * FROM tb_name WHERE id='your id'") or die(mysql_error());
                $i=0;
                while($row=mysql_fetcj_array($sql))'
                { $i++; }
                $i count how many items in this id
                if($i!=="0")
                {
                // item available
                }
                else
                {
                // not available
                }

                Comment

                Working...
                X