table question:
id question
1 myquestion1
2 myquestion2
3 myquestion3
4 myquestion4
5 myquestion5
table answer:
id qid userid answer
1 1 1 myanswer
2 2 1 myanswer
3 3 1 myanswer
4 4 1 myanswer
5 5 1 myanswer
My problem is how can i insert using php mysql for my answer after answering 5 questions?
any one has an idea?
sample question: After clicking radio button go to next question then after answering submit and insert answer into database..
Are you married?
Yes
No
Do you play basketball?
Yes
No
ect....
Any help very much appreciated!
Thank you!
array(
['question_id'] =>Yes //Are you married?
['question_id'] =>no //Do you play basketball?
)
You need to get this array by posting answer data
Related
Say i have a database with a table which i have numbers on. Is there some way that i can add 1 number digit onto another one. for example i query what the fist number is and then add 1 number on to that. like if it was 1 and i clicked a button it will make it 2. How would this be possible? At the moment i just add a 1 into a new row every time but i need it to be classified under names. and it is really easy the way i have it now. if you don't understand don't hesitate to comment.
mine. it adds up all the ones
1
1
1
1
1
what i need to accomplish.
joe frank 1
and when i click the link
joe frank 2
Does that make sense
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm trying to make a relation between two tables. I can do what I want with fetching the data with PHP and using returning value again in a query. But as far as I researched, it doesn't seem an efficient method.
How can I get the winning coupons when I'm finalizing the bet #3 as YES with a SQL query?
(It should return 3 and 4)
Coupon table,
ID coupon_id bets bets_played played_by
0 2 2 yes JOHN
1 2 3 no JOHN
2 3 1 yes JANE
3 3 3 yes JANE
4 4 3 yes SARAH
5 4 2 no SARAH
Bets table,
ID result
1 yes
2 no
3 NULL
Thank you.
select distinct c.*
from coupon c
join bets b on b.result = c.bets_played and b.result = 'yes'
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm thinking adding a number to a row, and in an array (or something) i can declare what it is.
Like this:
mySQL table
id type duration
1 2 5
2 3 4
3 6 10
PHP array or something
type 2 = jumping
type 3 = biking
type 6 = painting
This way it will be easier to add, or remove a "type".
But sorry, i have no idea how to do this.
The effect I'm looking for is to display
Johan was jumping for 5 minuts
Johan was biking for 4 minuts
Johan was painting for 10 minuts
Help much appreciated!
I would suggest to safe everything to a DB instead of hard-coding it in your code. So taking your table as basis:
Table: t1
id type duration
1 2 5
2 3 4
3 6 10
Table: t2
type_id whatever
2 jumping
3 biking
6 painting
You could use a SQL-Join to combine those two tables:
SELECT t1.id, t2.whatever, t1.duration
FROM t1
JOIN t2
ON t1.type = t2.type_id
will produce
1 jumping 5
2 biking 4
....
I have searched all over the internet and I have had no luck in finding the answer to my question. I hope this has not specifically been posted yet, but if you can point to where i can find the answer I would appreciate it.
I have set up a site that I am building into a fantasy golf site. I am using GravityForms as my form plugin. I have all the other features I want set, set up and need help with this last thing.
id lead_id form_id field_number value
1 1 1 1 Hosker
2 1 1 7 b**********#yahoo.com
3 1 1 6 Hyundai Tournament of Champions
4 1 1 3 Adam Scott
5 1 1 4 Harris English
6 1 1 5 2014-01-02 23:59:47
7 1 1 8 5b409692-e9ed-486e-8d77-7d734f1e023d
This is what my form submission gets posted as in the database. I would like to be able to take all of the data from this form and do an sql query and put it all in one row. Is that possible? The two columns that I will need to build my query around would be from lead_id and value where the value that I will be basing the query on is in row 7. The only value that I will know is in row 7. Thanks in advance for your help.
This is the result I am looking for
id lead_id form_id field_number value value value value value value value
1 1 1 1 Hosker b**********#yahoo.com Hyundai Tournament of Champions Adam Scott Harris English 2014-01-02 23:59:47 5b409692-e9ed-486e-8d77-7d734f1e023d
I would hook into the gravityform submission action and then perform whatever logic is required at that point to do the insert into the database.
add_action("gform_after_submission", "on_gform_submit");
Then create a function to accept the entry as an argument.
function on_gform_submit($entry){
}
Inside of this function $entry is an array that has the ID of each field (as per the back end) as the key. So if for instance message had an ID of 10, then it would be
$message = $entry['10'];
Then when you're done, simply input the data using a standard SQL Insert statement
Given a table like the one below, what would be the best way to detect the two columns separately?
So what I would need the total colspans for the first column.
What is important to remember is that the nr of columns can change.
In the case of this example, the second column starts at "10 euro" (second row). The first section is equal to 2 colspans. The other section is 5 colspans.
Any (abstract) ideas on how to do this?
You must consider the gaps in between the table cells and mark their positions, like this::
0 1 2 3 4 7
0 2 3 4 5 6 7
0 1 2 4 5 7
...
0 2 7
Once you have built an array with above information, you iterate over them and mark the common gap locations:
0 2 7
Since 0 and 7 are both at the edges of your table, you can strip those off. Then you're left with position 2 as the common gap between your rows.
Done :)