Dynamic textboxes value retrieval
i had dynamically created textboxes.two things are constant in all these texboxes -'class=data_textboxes','name=text_[name of textbox as per database value]'.
these textboxes are in a form and when i submit how can i access all those textboxes values either one by one or get all of them in an array.i need to do server validation on these values using php.
secondly i want to send these values to database,how can i the values to database(corresponding to its database value)
let me explain 2nd scenario wid n xample. suppose database company value is ="yahoo" then its corresponding textbox name will be name="text_yahoo" and there are lots of other companies..so how to send values of text_yahoo textbox to database refer开发者_如何学运维encing to yahoo??
foreach($_POST as $key => $value)
{
if(substr($key, 0, 5) == 'text_')
{
$fieldname = substr($key, 5);
$fieldvalue = $value;
.... add to database ....
}
}
Basically the idea is to look at field names and if they start with certain text then it's the field you're looking for.
精彩评论