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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:20:52+00:00 2026-05-30T12:20:52+00:00

I am new to programming and I found a working code which allows me

  • 0

I am new to programming and I found a working code which allows me to generate a table based from a query which also contains checkboxes in each row of the resulting table. How do I get/retrieve the values from the row/s which have been selected via the checkbox?

Here’s the code which generates the table:

<?php

        function SQLResultTable($Query)
        {
            $link = mysql_connect("localhost","root" , "") or die('Could not connect: ' . mysql_error());      //build MySQL Link
            mysql_select_db("myDB") or die('Could not select database');        //select database
            $Table = "";  //initialize table variable

            $Table.= "<table border='1' style=\"border-collapse: collapse;\">"; //Open HTML Table

            $Result = mysql_query($Query); //Execute the query
            if(mysql_error())
            {
                $Table.= "<tr><td>MySQL ERROR: " . mysql_error() . "</td></tr>";
            }
            else
            {
                //Header Row with Field Names
                $NumFields = mysql_num_fields($Result);
                $Table.= "<tr style=\"background-color: #000066; color: #FFFFFF;\">";
                for ($i=0; $i < $NumFields; $i++)
                {
                    $Table.= "<th>" . mysql_field_name($Result, $i) . "</th>";
                     if($i==$NumFields-1)
                     {
                     $Table.= "<th>&nbsp&nbspSelect&nbsp&nbsp</th>";
                     $Table.= "</tr>";
                     }
                }


                //Loop thru results
                $RowCt = 0; //Row Counter
                while($Row = mysql_fetch_assoc($Result))
                {

                    //Alternate colors for rows
                    if($RowCt++ % 2 == 0) $Style = "background-color: #FFCCCC;";
                    else $Style = "background-color: #FFFFFF;";

                    $Table.= "<tr style=\"$Style\">";
                    //Loop thru each field
                    foreach($Row as $field => $value)
                    {

                        $Table.= "<td>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp$value&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</td>";

                    }
                    //$Table.= "<td><input type='checkbox'></td>";
                    $Table.= "<td><input type='checkbox'></td>";
                    $Table.= "</tr>";
                }

            }
            $Table.= "</table>";

            return $Table;
        }
?>
  • 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-30T12:20:54+00:00Added an answer on May 30, 2026 at 12:20 pm

    A good starting point would be to read the information on how to select information from a database. With SQL generally this is done using SELECT statements. The MySQL SELECT documentation can be found here

    http://dev.mysql.com/doc/refman/5.0/en/select.html

    Using Google you should be able to find information regarding how to use a SELECT with MySQL and PHP. Once you’ve had a go, and if you still can’t figure out where you are going wrong, then post up a new question with specific information as to your problem and example code, and then I’m sure others will be able to provide you with advice relating to that specific problem.

    IMPORTANT

    As a security point of view, NEVER include usernames or passwords in your source code examples. Just put in placeholder values instead.

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

Sidebar

Related Questions

I'm reading Programming Perl , and I found this code snippet: sub new {
I am new to android programming and have found myself stuck I have been
I'm fairly new to programming and am working for my dissertation on a web
Still working through Programming Collective Intelligence and using Clojure to write the code. I've
I'm still new to C# programming and have been able to get WebDriver working
i been thinking of a new programming language. Before trying to implement it i
What features could be added to a new programming language to make it more
let's say that you in your new programming work your boss comes and says
What is the real benefit of creating a new programming language? It is highly
I always believed that when starting to learn a new programming language programmer must

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.