how to print checkbox results rows by rows using php?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • micropos
    New Member
    • Aug 2010
    • 4

    #1

    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","roo t","");
    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($qu ery)
    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><fon t face=arial size=3/>$field</font></td>\n";
    print "<input type=\"hidden\" name=\"username \" value=\"$val\"> ";
    print "<input type=\"hidden\" name=\"username \" value=\"$get_in fo\">";


    print "</tr>\n";

    }
    print "</table>\n";


    ?>
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    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:
    Code:
    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?

    Comment

    Working...