0

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

Edited by Dani: Formatting fixed

2
Contributors
2
Replies
29
Views
3 Years
Discussion Span
Last Post by Dzenad
0

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/>

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.