Hello,
I have stored values in database via html and php form. Now I am creating form which will enable users to edit inputs. I am having trouble with input types radio and checkboxes.

I have stored checkboxes values in database via implode function.
$products_rec=$_POST['products'];
$products=implode(", ", $products_rec); 

-----
My list of products is long (100 products), not all of them are stored in database. I have created edit form the same as input, and everything works fine except for checkboxes and radio inputs. I want to, for specitific id, chekboxes only stored in database to be checked in the box. I was wondering first is that possible?

-----INPUT FORM

<input type="radio" name="phones" value="Samsung">Samsung
<input type="radio" name="phones" value="Nokia">Nokia
<input type="radio" name="phones" value="Iphone">Iphone
--
<input type="checkbox" name="proizvodi[]" value="1">Samsung
<input type="checkbox" name="proizvodi[]" value="16"Nokia
<input type="checkbox" name="proizvodi[]" value="16">Iphone
<input type="checkbox" name="proizvodi[]" value="16">Toshiba
---
<input type="checkbox" name="proizvodi[]" value="1" <?php echo ($dbvalue['1']==1 ? 'checked' : '');?>>Samsung
<input type="checkbox" name="proizvodi[]" value="2" <?php echo ($dbvalue['2']==2 ? 'checked' : '');?>>Nokia
<input type="checkbox" name="proizvodi[]" value="3" <?php echo ($dbvalue['3']==3 ? 'checked' : '');?>>Iphone
<input type="checkbox" name="proizvodi[]" value="4" <?php echo ($dbvalue['4']==4 ? 'checked' : '');?>>Toshiba

I appreciate any help or advice
Thanks

hey :) i found something on stackoverflow that might be helpful.

Click Here

sorry if its not. do tell if it isnt.

I have found the solution. I have used implode function to store values in db.

<input type="checkbox" name="proizvodi[]" value="1"<?php if (strpos($row['PROIZVODI'],'1') !== false) echo 'checked="checked"'; ?>>Samsung <br/>

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.