I have a little form with php and javascript. It's a simple form with radio buttons and a couple of text boxes. Under the form there's a table , which is showing the values from the DB.
The php is taking the values of the text boxes and radio buttons and creating a special URL, which is the "Forwarder" in the picture below.
Now when I press the "Edit" button in the table, it must populate the current record with the values of text boxes and radio buttons into the form, so I can edit the values, creating another URL and update the record. The problem is, I don't know how to do it. There can be many records in the table. I don't know how to populate the form with the current record values. And I can't create a table in the DB for each of the values either.
Please can anybody give me some advice ? I will be very thankful.
Thanks beforehand.
On edit click you can run a select query based on the ID of the record. I see you are displaying it, so just grab the text of the ID field from the table. And we assume you have already saved the data from the form above...
Just create a page that gathers the information, and input fields to the table. I'm not sure if fields are static or not, but just populate all the fields manually.
Then have form set to GET type and on submit will be sent by url to the handler page where you could have Query String with PHP so for example index.php?title=TITLE&field1=VALUE
then use $_GET['title] and $_GET['field1'] to grab the information, grab them fields and save back to database.
Related
I have a registration form of residential complex with multiple levels, as you can see. I can edit and generate tabs by JS and jQuery, however I can't get the idea how to pass all that info to DB.
Screenshot:
How can I submit all that information into my MySQL DB from this form which generates dynamically?
How to correctly generate tabs (when press + button)? I mean using arrays $floor[0] and etc.
Do I submit it by parts, or I can do by 1 submit button, as well as on the screenshot?
The better solution is to use jquery wizard form.
Click Here for demo. you can store your data in single table and get all the data at the end of form submition.
As per my comment...
You can store all information in one database table.
After clicking on submit button from tab 1 the action perform to redirect to tab 2 and get all the values of tab1 to tab2 but make them hidden. Note: you can store all previous values in session or any other ways.
As like for tab 3.
After clicking on tab 3 submit button your sql query runs which insert all the values in database table.
Hope this will help you.
I have a dropdown, on its change I need to load the contents related to it on the same page. Which I did using jQuery. Now the question is how do I make edits on this data and store it on my database. If I am wrong in using jQuery for loading my data then what else should I use? I am using PHP as my server side scripting language.
More detail -
Simply taking there a list of details I need to display as per the country you select, which I am displaying currently in a nice grid(textboxes)!
Now the data from this grid should be copied to another textbox on "EDIT" button click from where I edit them and store it in my database. I am not able to make the values copy into a another textbox
You could do this:
Display the data in some form of editable div, textarea, or other element.
Make a hidden field somewhere and when you display the data
Set the row id from your database to the hidden field
On your change event, grab the id from the hidden field along with the edited data.
Using Jquery/ajax, send that data to a php page that will save thee data to your database using the passed in id.
You could do that.
However, if it were me (and if you're not married to your current databse / mySQL etc..), I would use parse.com. The service is free up to a significant amount of usage (which Ive never come close to) and it really simplifies everything. See the below post if you're interested in that approach:
Save and retrieve user input from database with javascript?
i have ASP page that contains clickable table with student information and when i click ID for student take me to update form filled with his information
how could i get these information in the update form ?
If the information is not sensitive, you could pass the value of the fields in the URL which then populates the fields in your update form.
If you add the code you are working with, then I'll be happy to give you a specific example.
I have cascading drop down form with 3 fields and 'Submit' button. Every field responds to each table in MySQL. So, if you choose an option from each drop down field and hit the 'Submit' button, the script returns and display an info of selected options. See an example: http://blueicestudios.com/chained-select-boxes/three-tier/
What I'm trying to do, is when every options are selected and the 'Submit' button is hit the link to the specific page should also displayed with an info of chosen option.
From an example: I selected a White Ford Mustang - For this type of selection I have a link to the page with a car in MySQL. But, I have no clue how to display it on the page. Any idea how to bring it to alive? Thanks
Just put the url in the form action:
$('form').attr('action','hondaCivicRed.php');
Or whatever they chose.
Submit will take them to the url
Edit:
$('document').on('change','#drop_3',function(){
var url = $('drop_1').val()+$('drop_2').val()+$('drop_3').val()+'.php';
$('form').attr('action',url);
});
It is actually quite a long answer to this question and too much code to write but here is the logic.
There are MUCH better ways of doing this (tables with JOINS etc.) but as a basic 'get it going' you just need to do the following (assuming you have worked out how to post the data and get the $_POST data back)
You could then set a table like so:
Manufacturer, Model, Colour, URL
Then just query the database with SELECT URL FROM table WHERE manufacturer=$_POST['manufactuer'] AND.....
(obviously the above is pseudo code but gives you the logic)
header('Location: $url); in your php.
Hope the above gives you an idea
The better way would be to dynamically create the pages from the database (so you dont need to create a new page for each colour, model etc.) but should give you a grounding
I'm trying to make an Invoice Table, later when the customer finishes, I want them to see the same product they ordered in another page!
I tried using HTML post method, but that doesn't work, because I'm using a JScript function to add rows and delete.
So to be clear, I want to know if it is possible to clone, or copy the entire table to another page with the content or without the content?
When you add and remove rows in your table,
you could also add and remove hidden form values for a form.
That form would have a submit button which sends you to the target page.
That target page takes the form values and produces a nice table again.
Either you take the form values with you with those hidden values
or you could store them temporarily in the session...
When users add and remove rows, the data is sent to the server, right? So just display the invoice on the other page. Or maybe I'm misunderstanding the question.