NameSilo

I need some advice

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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
Close
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
Close
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
Close
Could order_reference_number be
Code:
($row->order_id % 10000)
 
0
Close
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
Close
0
Close
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
Close
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
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back