php - Access a dynamically-set $_POST value -
i dynamically creating number of textfields , want insert values of fields database. each textfield associated youtube video pull api , carries name same url of youtube video.
the code have is:
if($youtube_video_database) { foreach ($youtube_video_database $key => $value) { foreach ($value $key => $value) { print "<div class='content row'> <div class='videos_and_comments col col-lg-12'> <div class='videos col-lg-6'> <iframe width='420' height='315' src='$value' frameborder='0' allowfullscreen></iframe> </div> <div class='videos col-lg-6'> <form method='post' action=''> <textarea class='form-control' name='$value' id='$value' rows='14'></textarea> <input type='submit' class='btn btn-default' name='submit' id='youtube_comment' value='submit'> </form> </div> </div> </div> "; print_r($_post); if (isset($_post['submit']) ) { print $_post['$value']; } } }
the print_r() gives me:
array ( [http://www_youtube_com/embed/ewucz8udopa] => want insert [submit] => submit )
both name , id of form carry url correctly, don't when try
print $_post['$value'];
really able change isset()
if (isset($_post['$value']) ) {}
but won't until can figure out how access value. i've not included mysql statement in code, i'm happy syntax of correct need access values need!
any appreciated!
you need change this:
print $_post['$value'];
to this:
print $_post[$value];
since variables , escape sequences (other \') aren't evaluated in single quotes.
Comments
Post a Comment