473,396 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to print checkbox results rows by rows using php?

hi everyone,who can help me solve the problem?i would like to print the checkbox result after ticked the selected checkbox,means how to retrieve the data from database of selected user?thanks.

<?php

include 'C:/wamp/www/micropos/condb1.php';

$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("customer", $con);


print "<table width=800 border=1>\n";
for($i=1;$i<12;$i++){

if(isset($_POST['cd'.$i]))

{
$val = $_POST['cd'.$i];

print "<input type=\"text\" name=\"username\" value=\"$val\">";
}



}

$result = mysql_query($query)
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=800 border=1>\n";
while ($get_info = mysql_fetch_row($result)){

print "<tr>\n";

foreach ($get_info as $field)
print "\t<td><font face=arial size=3/>$field</font></td>\n";
print "<input type=\"hidden\" name=\"username\" value=\"$val\">";
print "<input type=\"hidden\" name=\"username\" value=\"$get_info\">";


print "</tr>\n";

}
print "</table>\n";


?>
Aug 17 '10 #1
1 1976
TheServant
1,168 Expert 1GB
Use [code] tags.

Are you getting an error with your code above?

There are several errors but to get you started:
How can you call $get_info as a value in:
Expand|Select|Wrap|Line Numbers
  1. print "<input type=\"hidden\" name=\"username\" value=\"$get_info\">";
When two lines before you acknoledged it being an array with a foreach loop? Also, your hidden inputs have the same name? And it looks like you have already printed a text field called "username" (as well) with the value: $val?

So that form only has one value sent, which is "username", which is probably not what you wanted. I don't have time to go through the rest, but fix all that and detail any errors or things not working.

Also there are no checkboxes?
Aug 17 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Eduardo Hercos Rodrigues | last post by:
Hi, How to print directly from PHP code using CUPS? Thanks, "Eduardo Hercos Rodrigues"
2
by: Ken | last post by:
I have a db with the fields Day, Month, Year and Message. How can I select all of the messages for the current week starting with sunday and return the results as a list? Thanks Ken
5
by: Dave | last post by:
I tried posting this in the WinForm forum and got no hits so I am trying it here. After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row...
0
by: D. Bron | last post by:
Hello, I've been building my *.sln files from the command line using devenv.exe. The problem I have is that devenv won't print its results to stdout; I have to specify /out file.ext and then...
2
by: cabellm | last post by:
Hi, I am creating a web feedback form that has a both a checkbox and listbox on it that are both databound to a database. I have been researching all day and have found multiple answers for...
0
by: macupryk | last post by:
if (TEXTDT.Rows != DBNull.Value) {System.IndexOutOfRangeException: There is no row at position 10. at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex) at...
1
by: snsit1 | last post by:
Hello - i am wondering if anyone can help, I am fairly new to javascript / html and am having difficulty getting selected options ticked using check boxes out to a .txt file and have another script...
1
by: prathna | last post by:
Hi .. I have a logic:iterate tag which will display 5 rows each row with a drop downlist and 2 textfields.now by default all the rows will be shown.how do i hide all the rows except the first...
3
by: Max58kl | last post by:
Trying to access data and print it to the screen using Perl Builders I/O Window -------------------------------------------------------------------------------- Hi I am using a program called...
1
by: ahilar12 | last post by:
Hi all, I am new to php,my question is that in this following code i am retrieving many rows from the database which is working good.i want to delete a particular row(s) which is checked(checkbox)...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.