Jump to content

Push html link to array


Recommended Posts

Hi all,
I hope you can help me further with this problem. I want to build a quiz/votematch website like this one:
I want to ask about 20 questions and record all clicked items, so I can use it to match it after the last question. All questions are like this:

<div class="stelling" id="stelling4618">
<p>Question 1</p>
<h2>The question here.</h2>
<a address="true" href="#/stelling/2" class="big botshadow button agree">Eens</a>
<a address="true" href="#/stelling/2" class="big botshadow button neutral">Geen van beide</a>
<a address="true" href="#/stelling/2" class="big botshadow button disagree">Oneens</a>
<a address="true" href="#/stelling/2" class="medium button skip">Sla deze vraag over</a>

So if a user click on the first link, <a>eens</a>, I want to push this text to an array with php. After question 20 I want to show all clicked items and match it with my database values. How can I do this? Please help me, I really need this...


Thanks so much!!


Kind regards,


Link to comment
Share on other sites

Will all the questions be displayed at once? Or will the user answer one question, reload the page, answer another question, reload the page, etc.?


If all the questions will be displayed at the same time, you could build a single HTML form which passes all the responses to PHP at the end.


If the questions will be asked one at a time, you could display a form with the first question. The form would submit to a PHP script for processing. The script would display the next question while passing the previous responsive using hidden form variables or maybe a PHP Session variable. Then just repeat until all the questions have been answered.

Link to comment
Share on other sites

Hi CyberRobot,

Thanks for the quick response. All the questions are on the same page at once and are shown seperate with a javascript animation. So I html form is possible, only I want to style it like the example:



So I need to use html links instead of radio buttons. With Radio buttons it works, but I don't know how I can manage it with links like in the example. I've tried something like add an active state when the link is pressed, but I can't figure it out. I'm pretty new to php so I really want to learn this.


Thanks so much for helping me!!


kind regards,


Link to comment
Share on other sites

So please, what do you guys advise:

1: Create a form post with radiobuttons and try to style it like on the example

2: Use a a link attribute and send the data to php some other way?

I think option 2 is the best because radiobuttons aren't supposed to be styled like the example and links are more flexible. I can make the one clicked active like this (normal is active):

<a class="animatie knop active" href="#">Normal</a>
<a class="animatie knop" href="#">Bad</a>
<a class="animatie knop" href="#">Good</a>

So now I need a php code [when class=active post data to array/session]. Is this something that could work? Please, can anybody help me with this?


Thanks so much!!!

Edited by vistavision
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.