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

  • Home
  • SEARCH
  • 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 6748333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:33:09+00:00 2026-05-26T12:33:09+00:00

I have an id that i am trying to read from my database and

  • 0

I have an id that i am trying to read from my database and if it is equal to or less then the id i want to id++ until the id is not in the database and use that for the id of the form. Problem is i don’t know how to make a while loop that starts at number one and checks the database for that id if it exists then step the id until the id is not in the database and use that id for the form that is entered this is so a user can fill out a form and it emails a pdf to the user and another person the other person can pull up the form and edit it aka enter a new piece of data or the user can correct or change something on the form without reentering all the data. i have all the forms ready. i have a page to enter the id and pull up the form and it is already storing the data but i cant figure out how to make it generate a generic id for the order.

  • 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-05-26T12:33:10+00:00Added an answer on May 26, 2026 at 12:33 pm

    You should probably not manually be setting the ID in your table. Set your id field to the PRIMARY KEY make it an INT and UNSIGNED, last turn on AUTO INCREMENT. From there, the DB will automatically find the next value for your id and use it.

    Then in your php code, insert the newly filled out form into the database. and get the last insert id, to make a link to this prefilled form:

    $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db('mydb');
    
    mysql_query("INSERT INTO mytable (product) values ('kossu')");
    printf("Last inserted record has id %d\n", mysql_insert_id());
    

    Example off of php.net

    Additional Code block as requested in comments:

    mysql_query("INSERT INTO mytable (product) values ('kossu')");
    
    // GETTING THE ID
    $id = mysql_insert_id(); 
    
    //USING THE ID
    $body = "THIS IS AN EMAIL MESSAGE BODY, GO TO http://example.com/form.php?id=" . $id; 
    mail('bob@example.com', 'My Subject', $body);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a really simple XML file that I'm trying to read, but I
I have a form that is trying to insert some data into an SQL
I have an enumeration that I am trying to initialize from a long value
I am trying to read data from excel file in asp.net. I have added
I'm trying to read from an access database and put the results in a
I have an application that imports data read from text files from a directory
So I have a list of goods read in from a database and the
I am using List<T> array to store all ID's that I have read from
i have a coode that are trying to get the id of xml file
Here is my custom class that I have that represents a triangle. I'm trying

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.