Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7871095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:48:31+00:00 2026-06-03T01:48:31+00:00

I’ve been working on a survey system that reads the records(questions sorted by chapters

  • 0

I’ve been working on a survey system that reads the records(questions sorted by “chapters” you’ll see what I mean later) out of database and adds a score per record. The questions are stored in an array. so one record can hold for example five questions. let’s dive into the code

//echo the question list from the database

$query_questions = mysql_query("SELECT * FROM `vraag`");
while($result = mysql_fetch_array($query_questions))
{
//displaying the questions
echo "<br /><br /><b>";
echo $result['header']. "</b><br />";
echo $result['beschrijving']. "<br /><br />";
echo $result['onderwerp']. "<br />";

$aantal = $result['aantal_vragen'];
$id = $result['id'];
echo "<input type='hidden' id='number_of_questions' value=".$aantal." mousedown='calculate_score(this.value,0)'/>";
$array = unserialize($result['vraag']);
//retrieve the content from the array
for($i = 0; $i < $array; $i++)
{
        foreach($array as $value)
        {
            $array = $value;
            echo "<form><table><td>". $array ."</td>";
            echo "
            <td>1<input type='radio' name='vraag[]' value=1 onclick='calculate_score(".$aantal.",this.value)'/></td>
            <td>2<input type='radio' name='vraag[]' value=2 onclick='calculate_score(".$aantal.",this.value)'/></td>
            <td>3<input type='radio' name='vraag[]' value=3 onclick='calculate_score(".$aantal.",this.value)'/></td>
            <td>4<input type='radio' name='vraag[]' value=4 onclick='calculate_score(".$aantal.",this.value)'/></td>
            <td>5<input type='radio' name='vraag[]' value=5 onclick='calculate_score(".$aantal.",this.value)'/></td></table></form>";
        }
    echo "Uw totaal score is: <span id='total_score[]' ></span>";
    break;
}
}

what goes wrong is that it uses the last record of the query as the value to calculate with, it ignores the first record and the second and only picks up the last(third) record I want it to assign a score per record so shortly drawn out. The point of the radio elements is to make a point system ranking from 1 to 5 so it looks like: Question 1-2-3-4-5
this is my intention
[record 1]
score

[record 2]
score

[record 3]
score

but currently it works like this
[record 1]

[record 2]

[record 3]
score

I’m not entirely sure about the break command I have but I was testing if it’d fix my issue. For the score label thing I know I should increment the array by one each time it’s filled but I don’t know the syntax or if it is even possible at all to do so.
I’m new to stack overflow so forgive me any missing tags or anything other that’s unreadable or unpleasant on the eyes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:48:33+00:00Added an answer on June 3, 2026 at 1:48 am

    The outer for loop makes no sense. In the inner loop you are re-assigning $array while iterating over it (don’t really know what it does, but it’s just plain wrong).

    //Drop this code:
    //for($i = 0; $i < $array; $i++)
    //{
        foreach($array as $value)
        {
            $array = $value;   /* this is WRONG */
            /* ... */
        }
    echo "Uw totaal score is: <span id='total_score[]' ></span>";
    //break;   <--- don't need this either
    //}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.