Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,801 members, 7,806,228 topics. Date: Tuesday, 23 April 2024 at 01:16 PM

How Can I Generate Unique Random Num Wt Php Oop - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / How Can I Generate Unique Random Num Wt Php Oop (1359 Views)

How Can I Generate Money Using Facebook? / Who Is Good In Php Oop And Lives In Kano State? / After 5 Months Of Learning OOP In Visual C#-here Is A Little Project I Made. (2) (3) (4)

(1) (Reply) (Go Down)

How Can I Generate Unique Random Num Wt Php Oop by cr80vity(m): 8:44pm On Apr 25, 2017
good evening...
please i want to generate a unique random number for each registered user..
how can i write a php oop code to generate it? the random code will Start with 3 alphabets, end with 2 alphabets and 4 numbers in between

also, after generating it, how will I make it store in mysql database?

its a project given to me, please help me out guys...
Re: How Can I Generate Unique Random Num Wt Php Oop by yorex2011: 7:48am On Apr 26, 2017

Dude... Read up on generating random strings in php na..
You can use arrays or substr function for the alphabets, rand function for the numbers
Re: How Can I Generate Unique Random Num Wt Php Oop by cr80vity(m): 9:09am On Apr 26, 2017
yorex2011:

Dude... Read up on generating random strings in php na..
You can use arrays or substr function for the alphabets, rand function for the numbers

m learner so if I know I won't come here for help....
how can I let the code put 4 numbers in between the alphabets and how can I store it in database
Re: How Can I Generate Unique Random Num Wt Php Oop by teampregar(m): 8:21pm On Apr 26, 2017
A better approach will be to use only numbers instead. Because if you use two first alphabets, the probability of uniqueness will be a-z.. And for the middle numbers will only be unique to its placeholder domain(ie, 4000056 can only accomodate 1000000 - 4000056)... If you are on facebook try to download a photo on your news feed, it will have a file name like : 1508866654_5524343664_55600545_n.jpg . The numbers in this name was generated by a unique id generation system built by facebook..Twitter has open-sourced theirs with an API(search google for snowflake). I have also built one(Want to use it for a project) but it is copyrighted for now.
Re: How Can I Generate Unique Random Num Wt Php Oop by cr80vity(m): 2:38pm On Apr 27, 2017
pls guys, it will just be like a plate number
Re: How Can I Generate Unique Random Num Wt Php Oop by directonpc(m): 7:50pm On Apr 27, 2017
Nairaland is popular for this! You hardly get answers here.

I ain't doing better sha since a
I am not in the mode of providing answers. My advise search stackoverflow.com if you are unable to find an answer you can ask them there.
Re: How Can I Generate Unique Random Num Wt Php Oop by bet9ja(m): 7:25am On Apr 28, 2017
directonpc:
Nairaland is popular for this! You hardly get answers here.

I ain't doing better sha since a
I am not in the mode of providing answers. My advise search stackoverflow.com if you are unable to find an answer you can ask them there.

Majority of nairaland programmers reinvent the wheel.
Re: How Can I Generate Unique Random Num Wt Php Oop by directonpc(m): 9:14am On Apr 28, 2017
bet9ja:


Majority of nairaland programmers reinvent the wheel.
correct, you have summarized it.
Re: How Can I Generate Unique Random Num Wt Php Oop by yorex2011: 10:02am On Apr 30, 2017
Function generateId ( ) {
$rand_four_digits = rand(1000, 9999);
$aphabets = array("A",.... "Z"wink ; //list A to Z

//you generate a random alphabet using
$random_index = rand(0, 25);
$random_alphabet = $alphabets[$random_index] ;

//you can then generate more and concatenate

$generated_id ="whatever" ;
return $your_generated_id;

}


I'd suggest doing it in at least 3 different ways so you can learn

(1) (Reply)

/ Who Has Books On Python Programming Hard Copy For Sale / App Developer Need

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 61
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.