php - parsing dynamic POST variable -
php - parsing dynamic POST variable -
i have form may submit 1 line item or 200 quote. using fpdf create results , working perfectly, looking way automate picking post values. far have been doing them manually, hard create code changes:
//conditional statement verify values exist, otherwise write blank line $item=$_post['item3']; $uprice=$_post['uprice3']; $udprice=$_post['udprice3']; $quan=$_post['quan3']; //add values study //repeat next result $item=$_post['item4']; $uprice=$_post['uprice4']; $udprice=$_post['udprice4']; $quan=$_post['quan4'];
i wondering if there way add together variable within post value, $_post[$nextitem]?
you can loop until next number not available anymore:
<?php $i = 1; while (isset($_post['item' . $i])) { $item = $_post['item' . $i]; $uprice = $_post['uprice' . $i]; $udprice = $_post['udprice' . $i]; $quan = $_post['quan' . $i]; // stuff $i++; }
concatenating string 'var'
int 1
result in string 'var1'
in php.
php
Comments
Post a Comment