Forum Moderators: coopster
$pro1=addslashes($_POST['pro1']);
$pro2=addslashes($_POST['pro2']);
$pro3=addslashes($_POST['pro3']);
$pro4=addslashes($_POST['pro4']);
$pro5=addslashes($_POST['pro5']);
for ($i=1;$i==5;$i++){
if (!empty(${'pro'.$i}))
$pros.=${'pro'.$i}."\n";
}
echo nl2br($pros);
$pros return nothing, although $pro1 and $pro2 contain certain value. Any idea?
$pro1=addslashes($_POST['pro1']);
$pro2=addslashes($_POST['pro2']);
$pro3=addslashes($_POST['pro3']);
$pro4=addslashes($_POST['pro4']);
$pro5=addslashes($_POST['pro5']);
for ($i=1;$i<=5;$i++){
if (!empty(${'pro'.$i}))
$pros.=${'pro'.$i}."\n";
}
echo nl2br($pros);
Hey dude I'd like to thank you for this post. I have a dynamic form that's fields are generated like this
req_1
req_2
so on...
I've been pulling out my hair trying to get my loop:
for($l=1;$l<=$amount;$l++){
if($l==$amount){
$sql_text2.="'$req_$l'";
} else {
$sql_text2.="'$req_$l', ";
}
}
to post the guts of my sql statement then insert the info in the fields to the database. I just happened to check this post and I saw how you grabed the variables and then tied them into a new variable so now I've changed my loop to this:
for($l=1;$l<=$amount;$l++){
if($l==$amount){
$sql_text2.="'${'req_'.$l}'";
} else {
$sql_text2.="'${'req_'.$l}', ";
}
}
It worked like a charm!
Thanks dude!
Mike