20 行と 10 列のフォームがあり、要素 ID は _r1、_r2 などで区別され、クエリからすべての値を手動で割り当てるのではなく、それらをループしたいと考えていました。
何かのようなもの
//Set all mileage fields to empty
for ($i = 1; $i <= 20; $i++) {
$strTravelDate_r.$i = "";
$strHBE_r.$i = "";
$strPassenger_r.$i = "";
$strCongestionCode_r.$i = "";
$strTravelReason_r.$i = "";
$strAddress1_r.$i = "";
$strAddress2_r.$i = "";
$strDistance_r.$i = "";
$strRate_r.$i = "";
$strLineAmount_r.$i = "";
}
//Get mileage claims
$sql_miles = 'SELECT * FROM `tblsaved_mileage` WHERE `strUsername`="'.addslashes($username).'"';
$rs_miles = mysql_query($sql_miles);
$count_miles = mysql_num_rows($rs_miles);
$i = 1;
if ($count_miles > 0) {
while ($row_miles = mysql_fetch_array($rs_miles)) {
$strTravelDate_r.$i = $row_miles['strTravelDate'];
$strHBE_r.$i = $row_miles['strHBE'];
$strPassenger_r.$i = $row_miles['strPassenger'];
$strCongestionCode_r.$i = $row_miles['strCongestionCode'];
$strTravelReason_r.$i = $row_miles['strTravelReason'];
$strAddress1_r.$i = $row_miles['strAddress1'];
$strAddress2_r.$i = $row_miles['strAddress2'];
$strDistance_r.$i = $row_miles['strDistance'];
$strRate_r.$i = $row_miles['strRate'];
$strLineAmount_r.$i = $row_miles['strAmount'];
$i = $i + 1;
}
}
しかし、私はたくさんの
Notice: Undefined variable: strTravelDate_r in ........
Notice: Undefined variable: strHBE_r in ........
Notice: Undefined variable: strPassenger_r in ........