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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:42:02+00:00 2026-06-12T01:42:02+00:00

so i have this table in mysql called colegue in database addressbook1. it has

  • 0

so i have this table in mysql called colegue in database addressbook1. it has the following fields: colegue_id, firstname, lastname, telephone and email. what i want is to get the data within the firstname column and display it within a form that uses checkboxes.for example:
checkbox jerry
checkbox mary
checkbox cindy
and so on. then, the checked data is supposed to be sent to a script which echoes the data selected. here’s the code that loads data onto the page:

 <?php
 //connect to mysql
mysql_connect("localhost", "root", "");
//select database
mysql_select_db("adressbook1");
//select data from table
$query=("SELECT * FROM colegue");
//perform query
$result=mysql_query($query);
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>testing</title>
</head>
<body>
<h3>testing a checkbox form</h3>

<?php
//start the form
echo "<form method=\"post\" action=\"process.php\">";
while($row=mysql_fetch_array($result)) 
{
//assign value from associative array to variable
$data=$row['firstName'];
/*echo data and assign the value in the input the current value of $data while loading     onto array*/
echo "<input type=\"checkbox\" name=\"firstname[]\" value=\"<?php $data;?>\">".$data."    <br>";

}
echo "<br>";
//send data to process.php when clicked
echo "<input type=\"submit\" name=\"sent\" value=\"add\">";
echo "</form>";
?>
</body>
</html>

now for the script that processes the data:

<?php
//get the data from the form in an array
$entry=$_POST['firstname'];
//check if the array is empty or not
if (empty($entry))
{
echo("execution failed");
}
//if not empty, continue
else
{
//get the array size
$N=count($entry);
//display the size of the array
echo "$N"."<br>";
//this loop should display all the data in the array
for($i=0; $i<$N; $i++)
{

echo "$entry[$i]"."<br>";

 }
//end script by showing successful result
echo ("request successful!");

}
?>

the code runs fine when i check the names i want sent and submit them to the script. the script does show me the size of the array, (e.g. if i clicked on four names, it shows me the number four) but it doesn’t show me anything else, it doesn’t display the actual names that i clicked on the page. could anyone kindly help me solve this? i’m thinking that maybe i haven’t properly assigned values in the array firstname[].

Please note that i have to use this method (checkboxes) to submit the data gotten from the database so that it is displayed in the script-page. i am very new to programming, so i kindly ask for help, thanks.

  • 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-12T01:42:04+00:00Added an answer on June 12, 2026 at 1:42 am

    You need to concatenate $data with the string, just alter

    value=\"<?php $data;?>\"
    

    too

    value=\"".$data."\"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in my MySQL database called Sponsors . This table has
I have a MySQL database table called Participant that looks something like this: (idParticipant)
I have the following mysql table called test. lets say it has the data
I have a table like this in mysql called links_tbl which has 5 rows
I have a MySQL table called blocks with the following fields: blockid blockerloginid blockeeprofile
I have this mysql table called comments which looks like this: commentID parentID type
I have a MySQL table called accounts . Within this table is a field
I have MySQL InnoDB table utf-8 encoded. This table has only id and name
Suppose I have a MySQL table called MyTable, that looks like this: +----+------+-------+ |
I have a mysql table called pollOfTheWeek. It has a column pollDate of type

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.