Comdemned Posted October 1, 2007 Share Posted October 1, 2007 I am having a prblem pulling text out of $_POST running through a loop. <?php $num = $_POST['num']; for ($i=0; $i<$num; $i++){ $menu[$i] = $_POST["menu$i"]; $cred[$i] = $_POST["cred$i"]; $deb[$i] = $_POST["deb$i"]; echo "$menu[$i] : $cred[$i] : $deb[$i] : $i<br>\n"; } ?> $cred[$i and $deb[$i] are numbers and they come out fine. but $menu[$i] is text and I only get the first letter. $num is the number of loops run throught the form generation. so deb0 and cred0 are releate to menu0 and so forth. so instead of getting this from $menu[$i] default income other service insurance im getting d i o s i can anyone shed some light on this please. Thanks in advance Murray Quote Link to comment Share on other sites More sharing options...
marcus Posted October 1, 2007 Share Posted October 1, 2007 What are $menu, $cred and $deb equal to? If you look you're grabbing the first letter of each line of text. default income other service insurance Quote Link to comment Share on other sites More sharing options...
Comdemned Posted October 1, 2007 Author Share Posted October 1, 2007 $menu has 8 set posibilities from a drop down list. but there can be 100 $menu's as they are generated from lines of a csv file. so menu can = income, other, household, services, vechicle, rent_most, business, insurance the code that generates the form runs through a loop. The csv file can have any number of lines. <?php echo "<tr><td> $date </td><td><select id=menu$num name=menu$num><option value=default$num SELECTED>$desc</option><option value=income$num>Personal income</option><option value=other$num>Other income</option><option value=household$num>Household Spending</option><option value=services$num>Services</option><option value=vehicle$num>Motor Vehicle</option><option value=rent_mort$num>Rent/Mortage</option><option value=business$num>Business Costs</option><option value=insurance$num>Insurances</option></select></td><td valign=center> <input type=text name=deb$num value=\"$deb[$num]\" style=color:FF0000 readonly=yes></td><td valign=center> <input type=text name=cred$num value=\"$cred[$num]\" readonly=yes></td><td valign=center><input id=annual$num type=checkbox name=annual$num></td></tr>\n"; echo "<tr><td colspan=5 align=center><input type=hidden name=num value=\"$num\"><input type=submit value=\"Submit\" name=submit id=submit></form></td></tr>"; echo "</table>"; i need to pull each $menu[$i] and each value from $cred[$i] and $deb[$i], as you can see there are a lot of values I need. so as you can see there can be any number of dropdown menues Quote Link to comment Share on other sites More sharing options...
Comdemned Posted October 1, 2007 Author Share Posted October 1, 2007 Not 100% sure what i changed but not its working exactly how i want it to. thanks for all the help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.