PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
The bold lines are the ones giving me trouble. There is a table that is pulling info from a database. There are 2 fields (duration and distance) that require user info. The info is supposed to be passed to s 2nd page (add_activity.php). However, when data is entered, nothing is returned. Here,s what I get:
It seems the only way for me to get the values of the fields named duration and distance are to hard-code them. This, of course, is not ideal. So my question is: what can I do to get these values to pass? Do I need to change something? Any information is helpful!
dj262501 wrote:It seems the only way for me to get the values of the fields named duration and distance are to hard-code them
In the example script you gave, you have already hard-coded the values in? Just trying to clear up a bit of confusion because the output you show doesn't match the script (for me anyway).
If i understand correctly the information you don't want to hard-code is in the database, you just can't get them to display in the form? If yes, what are the names of the fields because you seem to have gotten it right with the value of 'exerciseid'. You apply the same principle to those fields as you did to the 'exerciseid' input tags.
The way you've done it, there are multiple versions of all those fields. They all have the same name.
Only the last one on the page will be available to you, and apparently it's empty.
Use arrays. Name your fields with a [] at the end and you'll get an array. For example,
1. String always need quotes, even if they're array keys.
2. The hidden input doesn't serve any purpose so it was removed.
3. You can't put BBCode inside [syntax] tags
dj262501 wrote:It seems the only way for me to get the values of the fields named duration and distance are to hard-code them
In the example script you gave, you have already hard-coded the values in? Just trying to clear up a bit of confusion because the output you show doesn't match the script (for me anyway).
If i understand correctly the information you don't want to hard-code is in the database, you just can't get them to display in the form? If yes, what are the names of the fields because you seem to have gotten it right with the value of 'exerciseid'. You apply the same principle to those fields as you did to the 'exerciseid' input tags.
I don't want to hard-code any of it. Duration and distance are textboxes in which the user must put information in. exerciseid is pulling information from a database, which is performing correctly. It's the two textboxes (duration and distance) that require user input that I can't seem to get it right without sticking a default value in them.
Last edited by dj262501 on Wed Sep 15, 2010 6:47 am, edited 1 time in total.
tasairis wrote:The way you've done it, there are multiple versions of all those fields. They all have the same name.
Only the last one on the page will be available to you, and apparently it's empty.
Use arrays. Name your fields with a [] at the end and you'll get an array. For example,
1. String always need quotes, even if they're array keys.
2. The hidden input doesn't serve any purpose so it was removed.
3. You can't put BBCode inside [syntax] tags
Dump out $_POST and see what you get.
I tried this, but it did not work. Maybe I did something wrong. It seems pretty logical though. I want to return the duration and distance of the $row['Name']. I don't know what else to do.