0

Hi People,

Got a php related issue..

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

Say for example,

Name:

Email

Address:

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.

Thanx.

2
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by fobos
0

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

<?php
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.

0

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

This topic has been dead for over six months. 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.