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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:49:14+00:00 2026-05-25T09:49:14+00:00

I’m working on a back-end functionality for a client. They want to be able

  • 0

I’m working on a back-end functionality for a client. They want to be able to add new records and edit old records through a very basic view; I’m slowly getting somewhere but I’m stuck now. I’m afraid I didn’t think my approach through from the start.

This is what it looks like at the moment:db update

The ‘Add’ fieldset slides out from under a button which isn’t showing atm. It does exactly what it says, add new records to the table. This works fine, I have succeeded in making the view dynamic (fields change per table, etc) and the insert statements work fine aswell. The problem, however, lies in the edit functionality.

When I press the ‘Edit’ button next to a record, the values of that row get loaded in the form above. The customer can then edit the values and submit them.. Or should be able to.

I’m stuck here. Mostly the update statement makes me want to bang my head against a wall. With the table showing, it isn’t exactly hard to write the query:

$this->db->where('guestid' => $guestid)->update($table)

The primary key here is guestid. I should use this id to know which row I want to update. However, at the moment, I don’t have a way to tell my form which row I’m going to update. I could make a hidden input field and put the ID in there.. But! I use this view, like I mentioned before, for different tables. Not every table has a guestid, etc. I could of course write a huge switch statement or if-structure to determine which table and thus which id should go into the hidden field, but I’m looking for an easier way.

This is mostly giving me headaches because some tables have a combined PK (E.G.: my table event_pass has a combined PK of eventID and passID). I’m unsure how to link this to the form and how to tell my application ‘look, update these values on this row with this PK’.

I have all the table metadata in an array, so I know the PK, etc.:

[eventID] => Array
    (
        [Field] => eventID
        [Type] => int(10) unsigned
        [Null] => NO
        [Key] => PRI
        [Default] => 
        [Extra] => 
    )

[passID] => Array
    (
        [Field] => passID
        [Type] => int(10) unsigned
        [Null] => NO
        [Key] => PRI
        [Default] => 
        [Extra] => 
    )
    etc..

Any help with my thought process would be appreciated here. I’m not looking for full code snippet, just some thoughts, suggestions on how to implement this and make my life a little bit easier. I can provide more screenshots of how other tables might look, and I can of course provide code if necessary. Thanks in advance.

  • 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-25T09:49:14+00:00Added an answer on May 25, 2026 at 9:49 am

    You need to get the primary key from the table with a SHOW INDEX FROM <table> query (see this) and send the primary key data to the page – as you suggested, a hidden input could be the way to do this, it’s certainly nice and simple and should do exactly what you expect it to in every browser.

    Then all you need to do is read that data when the request is submitted and build your where clause for the UPDATE query accordingly…

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

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
i want to parse a xhtml file and display in UITableView. what is the
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.