Dynadot โ€” .com Registration $8.99

I need some advice

Spaceship Spaceship
Watch

baris22

Established Member
Impact
1
hello,

I need some advice. This will be my mysql table

order
#order_id
#order_reference_number
#customer_id
...
....


order reference number is the number i need to give to customer. it needs to be a number. when it comes to 9999 it needs to start from 1 again.

how can i do this? what is the easiest way?

Thanks
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
order reference number is the number i need to give to customer. it needs to be a number. when it comes to 9999 it needs to start from 1 again.
Why does it need to start over at 1 once it reaches 9999?
 
0
•••
You could do a SQL check when you are insertting and see what the reference number is order by order_id DESC. If it is 9999, then you insert it as one, otherwise you +1 whatever the number is.

I wouldn't name your table order. That is a mysql function to sort.
 
0
•••
Why does it need to start over at 1 once it reaches 9999?

I do not know why. It is the way they want.

You could do a SQL check when you are insertting and see what the reference number is order by order_id DESC. If it is 9999, then you insert it as one, otherwise you +1 whatever the number is.

I wouldn't name your table order. That is a mysql function to sort.

thanks for suggestion. i will try and see if i can manage to do.
 
0
•••
Could order_reference_number be
Code:
($row->order_id % 10000)
 
0
•••
Could order_reference_number be
Code:
($row->order_id % 10000)

sorry.. my php knowledge is not very good. what does this mean? as output..

Code:
($row->order_id % 10000)
 
0
•••
0
•••
numbers

hello,

I need some help on numbers. I need to get the number for next
PHP:
<?=$row['id'];?>
and insert into
PHP:
<?=$row['reference'];?>
this is not a problem. i can do this

but

PHP:
<?=$row['reference'];?>
number can not be higher than 999. so when
PHP:
<?=$row['id'];?>
reaches 1000
PHP:
<?=$row['reference'];?>
should go back to 1.

When
PHP:
<?=$row['id'];?>
reaches 2000
PHP:
<?=$row['reference'];?>
should go back to 1. and so on....


Can anybody help me please.

Thanks
 
0
•••
The answer was given above: you need to use % (modulus)

The problem is, that this is not good for reference# as you will eventually get duplicates. How do you know which one to look up? You should just be using the order_id, and explaining to your clients as to why it is a bad idea to do what they are asking.
 
0
•••
Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back