PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Old February 6th, 2017, 05:01 PM
Banky Banky is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Feb 2017
Posts: 1 Banky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 42 sec
Reputation Power: 0
How to get values of dynamically generated text area field

I'm having a challenge with a mini project i'm working on and have googled for a solution for hours without a headway. Please guys i will appreciate your guidance on this. I have a column in my database table whose contents are generated by exploding a previous form inputs(separated by comma in the table). Now i need to get inputs (from users) for these values using textarea in a form. These inputs will be in arrays depending on the number of contents fetched from the db in the first place and then stored in another column in my table. The issue here is that each time i submit the form i get an undefined index notice for the name of the values in the textarea field,which is test-col []. please see my code below:

PHP Code:
<?php         
$conn 
mysqli_connect('localhost''root''''myDb');
$users_id mysqli_real_escape_string($conn$_GET['id']);         
$res mysqli_query($conn"SELECT tests FROM bal WHERE users_id = '$users_id'");         
if (
$res){          
while (
$row =mysqli_fetch_array($res)){          
$tests explode(','$row['tests']);         
foreach(
$tests as $test){             
if (
$test =="")    {
 continue;             }             
echo 
'<div class="test-res" style="margin-top:10px;">             <form action="" method="post" role="form" class="form-horizontal"        
<div class="form-group">
<label for= "test-col" class="form-label col-md-2">'
.$test.' test</label>
<div class="col-md-10">
<textarea class="form-control" rows="3" name="test-col[]" placeholder="Test result"> </textarea>
</div>             
</div>         
</form>     
</div>'
;     '<br /> <br />' ;     
} } } 
echo 
'<form action="" method="post">     <button type="submit" class="btn btn-success col-md-offset-5" name="sub-res">Send Result</button>
</form>'
;
 
?>

 //to insert textarea values in db 
<?php     
if (isset($_POST['sub-res'])){         
$conn mysqli_connect('localhost''root''''myDb'); foreach ($_POST ['test-col'] as $values){
$test_results implode("<br>"$values);     
}     
$ins mysqli_query($conn"INSERT INTO bal (results) VALUES ('$test_results') WHERE users_id = '$users_id'");     if (!$ins){
die(
mysqli_error());
}else{             
echo 
'<div class="alert alert-success">Successfully sent</div>';         
}     
}
 
?>

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > How to get values of dynamically generated text area field


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap