Jump to content

[SOLVED] $_POST["menu$i"] only showing first letter when run through loop


Comdemned

Recommended Posts

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

$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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.