0

I usually use CamelCase for PHP coding, but when it come to input fields name and table (DB) fields name... what should I use?

For example:

<input type="text" name="streetName" />
<input type="text" name="houseNo" />

or ...

<input type="text" name="StreetName" />
<input type="text" name="HouseNo" />

Usually I name the input fields the same as database table fields name.

I'll-Be-Back
  • 10,530
  • 37
  • 110
  • 213

3 Answers3

1

If you're using CamelCase for the rest of your project, it seems to make sense to me that you should also use it for input field names and table names.

Like people have said, there isn't really a right answer to this question, it's more of a personal preference. Personally I think you should just choose a method and stick to it, whether than involves a different naming convention for inputs and tables then that's fine I guess, as long as it makes sense to you, and you're happy with it (and think it makes sense)

Sean
  • 6,389
  • 9
  • 45
  • 69
0

There is no good or wrong answer to this question. My preference goes to the first example given by you because of readability.

stUrb
  • 6,612
  • 8
  • 43
  • 71
0

Do whatever floats your boat. Upper-casing the first letter is usually reserved for class names in most OOP languages. Personally I underscore my input fields.

Just don't reinvent the wheel. Look for a common standard on big sites like Facebook, Twitter, etc and see how they're doing it.

AlienWebguy
  • 76,997
  • 17
  • 122
  • 145