Hi,

I want to have multiple selection checkbox in my website, where user can check for the multiple options.

But for checkbox i should get the data from the database table.

$query2 = "select * from Products where CategoryID = '$CategoryName' ";
 mysql_query($query2) or die(mysql_error());
 $array = array();

while($row = mysql_fetch_assoc($query2)){
$array[] = $row;}

I dont know is this the right way. but after this i dont know what to do. Please help me with the script . thanks

Hello somebody can help me in this

Not entirely sure what you're trying to do, but how about this:

$query2 = "select * from Products where CategoryID = '$CategoryName' ";
$result = mysql_query($query2) or die(mysql_error());
if ($result && mysql_num_rows($result)>0) {
    while($row = mysql_fetch_assoc($result)){
        $array[] = $row;
    }
}

But why you want to transfer the data from one array to another beats me.

If you're wanting to use the data for a series of checkboxes, why not do that instead:

$query2 = "select * from Products where CategoryID = '$CategoryName' ";
$result = mysql_query($query2) or die(mysql_error());
if ($result && mysql_num_rows($result)>0) {
    while($row = mysql_fetch_assoc($result)){
        echo "<input type=\"checkbox\" name=\"fieldname\" value=\"{$row['product']}\" /> {$row['product']}<br />
    }
}

would save you a step

commented: Correct +4

Hey thanks a ton! it worked for me... thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.