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 6016417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:58:46+00:00 2026-05-23T02:58:46+00:00

for($j = 0; $j < $length; $j++){ while($answersRow = mysql_fetch_row($fetch)){ if($answersRow[0] == $curr_answer_id[$j]){ echo

  • 0
for($j = 0; $j < $length; $j++){
    while($answersRow = mysql_fetch_row($fetch)){
        if($answersRow[0] == $curr_answer_id[$j]){ 

            echo "<input type='checkbox' value='$answersRow[0]' checked>$answersRow[1]</input> ";           
        } else {

            echo "<input type='checkbox' value='$answersRow[0]'>$answersRow[1]</input> ";           
        }
    }
}

Assuming $fetch is my result, here’s my dilemma. The for loop represents the array of checkboxes. The first loop around, everything works fine. However, any more than that, we no longer cycle through the while loop because of the internal mysql pointer. I know I can move the pointer around using mysql_data_seek(), but don’t have an idea on how to do so usefully. If I move it back to 0, then it just outputs everything for as many things that were checked.

I basically want to traverse through for each question through the database but without any overlap. It is a bit hard to explain so I apologize if I am not explaining this simple problem properly; I’ll try and clarify if need be.

  • 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-05-23T02:58:47+00:00Added an answer on May 23, 2026 at 2:58 am

    You can save the results of your first while in an array:

    //> FIRST LOOP
      while($row = mysql_fetch_assoc($query)) {
        $rows[] = $row; //> Saving in the $rows array
        //> All your code from your first loop
      }
    
    //> SECOND LOOP    
      foreach($rows as $v) {
       //> All your code you need for your second loop without any additional query
      }
    

    Also sorry If I misunderstood your question but It is not so clear what you are asking for

    Addendum

    After reading better your question if I understood correctly you want to achive everything within only one loop. In this case you can save the html you need in the first while like this:

    $firstLoop = '';
    $secondLoop = '';
    while() {
       $firstLoop .= '<option> [...]';    
       $secondLoop .= '<div> [...]';
    }
    

    At this point with one loop you have built the html you need and they are in $firstLoop and $secondLoop. This is of course faster then any other solutions

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While googling, I see that using java.io.File#length() can be slow. FileChannel has a size()
Consider the following code: client.Send(data, data.Length, endpoint); byte[] response = client.Receive(ref endpoint); While, according
$(.sectionHeader).click(function() { var row = $(this).parent(); while (row.next().length != 0) { row = row.next();
string strLine;//not constant int index = 0; while(index < strLine.length()){//strLine is not modified}; how
int length = strlen(src); char *structSpace = malloc(sizeof(String) + length + 1); String *string
Why is Array.Length an int, and not a uint . This bothers me (just
I get the Total length of columns in constraint is too long. erro from
What is the maximum length in characters a CString object can hold?
Is there a maximum length when using window.returnValue (variant) in a modal? I am
What is the maximum length for the text string contained in a CEdit control

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.