Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7740599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:49:17+00:00 2026-06-01T08:49:17+00:00

Possible Duplicate: Algorithm for generating a random number is posible to generate a random

  • 0

Possible Duplicate:
Algorithm for generating a random number

is posible to generate a random number that is never repeated??

Is there a solution in php? or codeIgniter?

for example if i need to generate a random never repeated id for every user, how can i be sure that no user will have the same id?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:49:18+00:00Added an answer on June 1, 2026 at 8:49 am

    Clearly speaking, there is always a chance for a number since every form is generated from same algorithm generally.

    The safest way would be to check you database to ensure that, if an id is already taken like:

    $id = "1"; //Your id to check
    $query = "SELECT * FROM table where id=?";
    $result = mysql_query($query);
    if(mysql_num_rows($result)) { 
      //the id is present
    }
    

    It will be better if you use mysqli instead

    $id = "1"; //Your id to check
    $query = "SELECT * FROM table where id=?";
    $stmt = mysqli_prepare($link, $query);
    mysqli_stmt_bind_param($stmt, "i", $id);
    mysql_stmt_execute($stmt);
    if(mysql_stmt_num_rows($stmt))
      //the id is present
    }  
    mysqli_stmt_close($stmt);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Algorithm for generating a random number Hi i need to assign a
Possible Duplicate: How exactly should I implement a shuffle or random-number algorithm for an
Possible Duplicate: Solution to a recursive problem (code kata) give an algorithm to find
Possible Duplicate: Generating all Possible Combinations I'm trying to do a little algorithm in
Possible Duplicate: Algorithm to find Lucky Numbers I came across this question.A number is
Possible Duplicate: Algorithm to find minimum number of weighings required to find defective ball
Possible Duplicate: Best algorithm to count the number of set bits in a 32-bit
Possible Duplicate: Best algorithm to count the number of set bits in a 32-bit
Possible Duplicate: Best algorithm to count the number of set bits in a 32-bit
Possible Duplicate: C#: Is using Random and OrderBy a good shuffle algorithm? I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.