[need] availability check from stock

Started on the old forum in May 2013 · view the original in the archive · old links redirect here

7 replies · 463 views · started 13 years ago · 1 min read

4 participants
asifnayem Developer · 119 posts #1

Hi,

This thread is mostly related to my old thread (http://coding-talk.com/f14/%5Bneed%5D-array-db-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.

	$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?

asifnayem Developer · 119 posts #2

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

something else Fellow · 2,296 posts #3

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

asifnayem Developer · 119 posts #4

something else wrote: 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?

arnage Lead · 811 posts #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***
asifnayem Developer · 119 posts #6

arnage wrote: 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?

arnage Lead · 811 posts #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.

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
Lue_chin Developer · 107 posts #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 }

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close