Function-Database Help
I am using an extension for Joomla! called Breezing Forms. I can add custom functions (php) to the form, I need to do the following things:
1) If I开发者_StackOverflow社区 have a dropdown list with cities-
eg: New York, Los Angeles, Miami and each city has its own value eg: 1, 2, 3
I have two rows in a database table, one for the id, and one for the actual city name. What kind of function do I need to make to just select one value from a list in a form, but populate both rows like above?
2) How can I have the value of one text field in a form be the same for two rows in a table?
3) What function do I need to pass the date (in Y-m-d format) to a row?
Thanks for any help! I'm not too good with PHP code, I'm more of a designer.
I'm assuming you mean columns and not rows? And do you want to know how to connect IDs with names? If so, you will need to use SQL JOINs. For example, cities table:
city_id, city_name
1, 'New York',
2, 'Chicago',
3, 'Los Angeles'
And a user table with city IDs
user_id, name, city_id
1, 'test', 1,
2, 'jdoe', 3
Now, you can use a join on this.
SELECT u.user_id, u.name, c.city_name
FROM users AS u
LEFT JOIN cities AS c ON c.city_id = u.city_id
I don't know what mean by question 2, but you can use the date() PHP function to pull specific dates. Hope this helps.
精彩评论