php - How to insert data into table taking table name value from form? -
<? if($_post['submit']) { $taskselect =$_post['taskoption']; $sql =array(); foreach($_post['task'] $key => $value){ $sql[] =mysql_real_escape_string($value); } $ab ="insert into" .$taskselect. "(u_id,task) values ('".$_session['id']."','".implode(',', $sql)."')"; } $asc =mysql_query($ab); ?> html is possible , i've tried no value being inserted table when i'm using table name taken form? <select name="taskoption"> <option value="today">today</option> <option value="weekly">weekly</option> <option value="month">monthly</option> </select> you miss spaces: $ab ="insert into" .$taskselect. "(u_id,task) values ('".$... should $ab ="insert " .$taskselect. " (u_id,task) values ('".$... that bein...