Jump to content

MySQL value into option box then populate textboxes.


kielly32

Recommended Posts

Not sure if I'm even allowed to post here without any code, but I'm not asking anyone to code.

 

I'm currently trying to design an admin panel that can manage user reports created from a report form. I have it set so only admins can access this panel via sessions and now I need to design the form its self. The problem is I'm fairly new to PHP and barely knows where to start.

 

I need a option box to populate from a table, that option box needs to have the values of the report ID's. - I have that much done and completed.

 

Next part is I need textboxes (report type, report comment, and admin resolution) to populate depending on the report ID (value of the option box).

 

From what I gathered, I either need to do that action with js, ajax, etc or code it to a button. 

 

My problem is I don't know any of the code to write, nor do I know anything about any language besides PHP/HTML, CSS. 

 

I've searched, and searched, and searched, and searched all through Google. Trying different keywords, phrases. All I could find was outdated guides that uses MySql. There are no guides or pre-made codes that I could find that is using MySqli. 

 

Maybe im just crazy, but it seems there's very little how-to guides and help on the internet when it comes to mysqli. I almost feel like reverting back to an old php version.

 

So I guess my question is, does anyone know of a guide online, or a similar question with code that was resolved that would fit this situation?

Link to comment
Share on other sites

I need a option box to populate from a table, that option box needs to have the values of the report ID's. - I have that much done and completed.

 

From this sentence alone, it appears that you do have code that you could have provided

 

Not sure if I'm even allowed to post here without any code

 

That aside, you've already answered your own question as to which keywords to use in your Google searches.

 

From what I gathered, I either need to do that action with js, ajax, etc or code it to a button.

 

In my simple search for js ajax, I'm presented with a plethora of results and good examples and tutorials.

 

 nor do I know anything about any language besides PHP/HTML, CSS. 

 

Well, buckle up!  If you only know those three fundamental languages then you're 75% of the way there to being an actual developer.

 

To sum up what needs to happen in your code, however you chose to write it (given the tutorials from the google results):

 

You have your HTML form on one page, you then create a separate file written in PHP to validate things for you and return data that you can use on your HTML page.  Using JavaScript, you can perform an AJAX call to your PHP script, sending it the data to validate.  In your same AJAX calling code, you are not only able to just send the data, but you are also able to receive the data; that's what AJAX stands for Asynchronous JavaScript and XML.  Because the call is asynchronous, your page doesn't have to wait for the response from your PHP script.  Your user will never even know the call to the PHP script is being made unless they're looking at their Network panel in Developer tools.  So, if your PHP script takes a really long time to execute, it doesn't mean the user's page freezes like it would with a synchronous call to the PHP script.

 

As I mentioned, in that same AJAX call to the PHP script, you can define what happens whenever the PHP script is finished executing.  You can also define exactly what happens when the call has failed.  The possibilities are endless in what you can accomplish with an AJAX call.  Those possibilities are even more infinite if you know JavaScript!  So, start practicing your JavaScript and follow some AJAX tutorials.  Come back with your findings and provide actual code next time  ;D

 

Personally, I find this example tutorial to be perfect for understanding the fundamentals and basic procedure of how an AJAX call is made.

https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX/Getting_Started

 

There are also libraries out there that make this an even more streamlined process, such as jQuery.

Link to comment
Share on other sites

I fail to see why you see this as being so difficult. Ajax? Why? JS? Why?

 

Design a form that contains the inputs that you need for your db(?). That's what you are describing, isnt' it?

 

You want to have an admin form that allow one to either fill in descriptive attributes of a report that has been produced OR you just want a form that displays those attributes. Not sure from your post. So you create an html form for those fields with some divs, some labels, some inputs and an input/submit button to process the form data. In a basic form you won't need any JS nor any Ajax. Then you send that form out and await the response. Your php script then looks for a proper response, grabs the inputs and validates them (always check all user input!) and then performs whatever task you want to have done with that data.

 

As a beginner you should probably focus on a good html tutorial for a basic d/e form if that is what you need. If no d/e needed then simply find a form that displays some data fields for you. Keep it simple until you are comfortable with the effort. Then focus on a php script that retrieves POST data from a form. Read up on how to do that in a secure fashion. After that if you are going to do something to save those inputs read up on how to do a proper query statement and how properly prepare that statement.

 

Seeing that you only have 3 posts on this forum I gather you are very much a beginner. My recommendation is to start small and slow and LEARN things as you build this. It doesn't sound like a hard project - it just comes across that way to me since you have so many thoughts present in your post. You need to step back and just pick out the basic features of your app and see them as separate blocks and work on them one at a time.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.