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 6187417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:03:16+00:00 2026-05-24T02:03:16+00:00

I have an html form (each form has different page, according to date), with

  • 0

I have an html form (each form has different page, according to date), with five text inputs, called date, inp1, inp2, inp3 and inp4.

For example, I have database table, with structure like this: id | parent | name | value.
In this case, I want to store my data, and adding it to date by parent, like this:

id | parent | name | value
1  | 0      | date | 20.07.2011
2  | 1      | inp1 | value-from-inp1
3  | 1      | inp2 | value-from-inp2
4  | 0      | date | 21.07.2011
5  | 4      | inp2 | value-from-inp2
6  | 1      | inp3 | value-from-inp3
7  | 4      | inp1 | value-from-inp1

and so on…

But problem starts here. I want to create option, that you can update those values for previously added.
But the QUESTIONS are, how to check, if

  1. Do I have anything assigned to that date already?
    1. If is assigned, how to determine, and use MySQL Update for that
    2. If is not assigned, how to determine, and use MySQL Insert Into for that

My stupid and 50% more inefficient of loading page solution for this problem sounds like this (Don’t worry about security, its just mock-up):

if($_POST['submit']){
$inp1_data = $db->get_row("SELECT name FROM table WHERE parent = ".$parent_id." and name='inp1'");
if($inp1_data){$db->update($query)}else{$db->insert($query)}

// ... and so on, four copies of same code, just replacing "inp1" to "inp2", "inp3"...
}

Yes, I know, this is useless script, in case, if I have added one more, or hundreds of inpNUMBER, it would be crush test site, 100% guaranteed timeout, not working script.

  • 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-24T02:03:18+00:00Added an answer on May 24, 2026 at 2:03 am

    It sounds to me like you’re trying to use a singe table where you really need two. To answer your question, because the date is stored separately from the value, there is no way to find out if you have a value assigned to a particular question using a single SELECT. You may be able to do this with a nested select, but I won’t try to go through the contortions to make it happen.

    Consider this alternative design, which assumes that a given field can’t be repeated for a given submission:

    Submission table

    submission_id | date
    1             | 20.07.2011
    2             | 21.07.2011
    

    answers table

    submission_id | field_name | field_value
    1             | inp1       | value-from-inp1
    1             | inp2       | value-from-inp2
    2             | inp2       | value-from-inp2
    2             | inp4       | value-from-inp4
    1             | inp3       | value-from-inp3
    

    Note that Randolf Rincón-Fadul’s suggestion of keeping the data types separated by field is a good one, but I haven’t done it here to keep things simple. Now you can find out if you have an answer for a particular date by joining the tables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have an html form. Each input/select/textarea will have a corresponding <label>
I have an HTML form with plenty of inputs, most of which are optional.
I have a page in JQuery mobile, which contains a form. The form has
I have one HTML <form>. The form has only one action= attribute. However I
I have an HTML form - with PHP, I am sending the data of
I have a HTML form, and I have a Controller Action that accepts the
I have an HTML form generated by JSF which maps an input element to
I have a html form for uploading a file, which is as follows: $uploadhtml
I have a HTML form containing checkboxes in the form of .. <input type=checkbox
I have an HTML form where the user can type in any number:5, 8,

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.