I was confused for a moment about the use of the "two" checkboxes in your
request -- now I understand that you actually use the word "checkbox" for
two different items in your post.  1) is for the field in the table where
binary data is fetched and 2) is for an actual HTML form checkbox that is to
precede each row of data.

Your script only displays #1 -- the data from the database.  Here is what
you need to do to see the checkbox before the data in each row.

    echo " <input type=\"checkbox\" name=\"c_box\" value=\"$checkbox\">  $id
$checkbox $testField <br>";

I am assuming a couple of things with the above code -- but this should get
you to the place where you can work it out.

Mark Cain

----- Original Message -----
To: <php-db@lists.php.net>
Sent: Friday, June 24, 2005 5:25 AM
Subject: [PHP-DB] mysql check boxes

Dear Friends,

I have mysql database and php script.

Script pulls all the data with their serial number in html form, from
database however, I want each field pulled to be preceeded by a check box.

I created field in table and entered array for check boxes in php script,
still check boxes aren't displayed.at the same time rest of the data with
number is displayed.
Php script
// open the connection
$conn = mysql_connect("localhost", "cde_mail", "h63");

// pick the database to use

// create the SQL statement
$sql = "SELECT * FROM subscriber";

// execute the SQL statement
$result = mysql_query($sql, $conn) or die(mysql_error());

//go through each row in the result set and display data
while ($newArray = mysql_fetch_array($result)) {
    // give a name to the fields
    $id  = $newArray['id'];
    $checkbox  = $newArray['checkbox'];
    $testField = $newArray['email'];
    //echo the results onscreen
    echo "  $id $checkbox $testField <br>";
mysql table structure
   Field         Type            Attributes   Null    Default Extra
    id             int(11)           No               auto_increment

    checkbox char(2)         BINARY   No []
    email    varchar(150)  No

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to