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

  • SEARCH
  • Home
  • 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 3721738
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:39:36+00:00 2026-05-19T05:39:36+00:00

I have a while() function that loops a row of data within my table.

  • 0

I have a while() function that loops a row of data within my table.
Now What I need to to have a dropdown within 1 particular column of every row.
This dropdown is executed by utilizing a loop as well.

So here is the function that creates the dropdown:

function createDropdown($total)  
{  
    $i = 1;  
    echo "<select>";  
    while($i <= $total)  
    {  
        echo "<option value = '$i' id =* '$i'>$i</option>";  
        $i++;  
    }  
    echo "</select>";  
}

To print the table:

while($row1 = mysql_fetch_array($result1))  
{  
    print("<tr>");
    printf("<td>%s %s</td>", $row1["fname"], $row1["lname"]`);  
    printf("<td>".createDropdown($count)."</td>");  
    printf("<td colspan = '2'>%s</td>",$count);  
    printf("<td><span id = 'attendance'>111</span></td>");  
    print("</tr>");  
}

So now I have many dropdowns of which gives me what I want.
The problem is, I need to post all of these in the next page. Which means the ID of each dropdown has to be somehow be put into an array.

Anyway I can do this? Thanks in advance.

To make things clearer, the <select> can have any ID, but the problem is, every dropdown would have the same ID. When using $_POST, I will only attain the value from the last dropdown, not all of them. I have to array the dropdowns itself, which I have had problems with for some time.

  • 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-19T05:39:38+00:00Added an answer on May 19, 2026 at 5:39 am

    How about this (sorry, I’m also a bit unclear on what you’re asking):

    function createDropdown($num, $total)
    {
        $i = 1;
        $result = "<select id='sel$num' name='sel$num'>";
        while($i <= $total)
            {
            $result .= "<option value = '$i' id = '$i'>$i</option>";
            $i++;
            }
        $result .= "</select>";
        return $result;
    }
    
    
    $num = 0;
    while($row1 = mysql_fetch_array($result1))
    {
        print("<tr>");
        printf("<td>%s %s</td>", $row1["fname"], $row1["lname"]);
        printf("<td>".createDropdown($num++, $count)."</td>");
        printf("<td colspan = '2'>%s</td>",$count);
        printf("`111");
        print("");
    }
    

    I’ve changed your echos in your function and made it return the string instead (I think this is better style), and the select boxes will be given the name (sel0, sel1, sel2, etc…)

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

Sidebar

Related Questions

I have two simple while loops in my program that I feel ought to
I have read that while plug-ins are not supported for SQL Server Management Studio,
I have this code while($row = mysql_fetch_row($result)) { echo '<tr>'; $pk = $row[0]['ARTICLE_NO']; foreach($row
I'm trying to page a table, and while I have paging already working, it
I have a table, containing a checkbox to select the whole row (or not).
I have this JavaScript code: for (var idx in data) { var row =
I have a table that's generated by a normal PHP loop. What I want
I have a single column table which looks like this: Gaming | Austria |
I need to extract data from a DB2 table, run some processing on each
I have a php function that dynamically queries a database, and returns 6 tables.

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.