Hi People,

Got a php related issue..

I have a form Which has some textboxes, few checkoxes and a Textarea.

Say for example,




And then the checkbox values.......

Hobbies (Reading, Trekking, Gardening, Outdoor Sports, Birding)

Once I click the submit button, All my data gets inserted in the database. I'm storing the checkbox value as a string in the Hobbies column in the database.

Now I wanna retreive my data, for this I'm showing my stored data in tabular format and corresponding to each row is an EDIT link.

Once I click the EDIT link....... The same form gets displayed, but all the set of values of that particulr row gets popped up in those textboxes. I can then Edit it and after clicking submit my data gets updated in the database.

Problem is with checkbox.

Say, while filling the form, I had selected

Name: Albert

Email: albert@yahho.com

Address: USA

and from Hobbies only Reading and Trekking were checked and submitted.

Now when I click on Edit link. I waana retreive the stored data from database and pop it into respective textbox. That is working fine. Problem is I wanna display all the checkbox values but only Reading and Birding as checked, since these 2 values were checked at the time of form submit.

I hope I'm clear.

Sorry for the lengthy post.


Recommended Answers

All 3 Replies

well if your database has a row for each checkbox value, then you could just use the if statement:

if(!isset($row['hobbies']) == NULL) {
    echo "<input id='hobbies' type='checkbox' value='Hobbies'>";
} else {
    echo "<input id='hobbies' type='checkbox' value='Hobbies' checked='checked' />";

Dont know if this helps, but its a start.

Thanx Sir, for your reply...

Actualy I'm using implode to convert my data into a string and then storing it in the database.

Now when I wanna recover the checkbox values, I wanted it in the checkbox format in the front end..... With only those checkbox values checked...which were earlier checked and submitted....

well your going to have to post your code for us to see. but here is another link you can look at Click Here, or Click Here, or Click Here

Be a part of the DaniWeb community

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