Converting fields in php forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jescobar
Forum Newbie
Posts: 24
Joined: Mon Jun 06, 2005 4:14 am

Converting fields in php forms

Post by jescobar »

I am trying to convert a form field into another. So let me explain this the best I can...

I have a form with some check boxes I am going to use so users can update their profile preferences. The provider I am connecting to, where all the profile data is stored (database) only has options for text boxes. So I am wondering how I can convert the values, for example, making the values "Y" and "N" for the text fields and the "Y" would have the check box checked where "N" would do the opposite.

Here is a chart to do some talking for me, in case I dropped you somewhere in the Y and N lingo.
forms.jpg
forms.jpg (29.86 KiB) Viewed 205 times
For some reason, the company hosting the database only lets us create text fields (per their customer service) so I have to find a way around this.

Thanks for your help,
Don
buckit
Forum Contributor
Posts: 169
Joined: Fri Jan 01, 2010 10:21 am

Re: Converting fields in php forms

Post by buckit »

Im not following... you are talking about Forms, PHP and databases as if they are all 1 thing. Those are 3 very different technologies.

so what do you want the form to be? check box or text box? am assuming checkboxes... I guess where you are losing me is when you say "where all the profile data is stored (database) only has options for text boxes". Databases dont have text boxes. A database has a table with columns and each column as a row with values. now a column can be configured for specific types of data. is this what you are talking about? the database can only take text?

maybe this will help you figure something out... think of a check box as true or false, 1 or 0, or on and off. you only need to decide how you want to interpret that. Personally, I would say that checked = 1 and unchecked = 0. so enter that value into the database. make sense?
User avatar
jescobar
Forum Newbie
Posts: 24
Joined: Mon Jun 06, 2005 4:14 am

Re: Converting fields in php forms

Post by jescobar »

You are correct, this is a little confusing. I'm aware that the database has columns and rows, if I had full control over the input fields I would simply use a checkbox for the on and off feature that I'm wanting here.

However, the company I'm going through doesn't let me create checkboxes for the input fields. The only option they have, to input data to the database is a text field. I have no problems using 1 or 0, Y or N for the values, my problem is translating that between the checkboxes the user would see and the control panel text box.

In other words, the end user would see a check box within their profile form, check it and pass a 1 to the text box that sends the information to the database. My problem is the translation between the checkbox and the values in the text field.
Post Reply