php - Increment Index in $_POST Array -
i have section of php code need $_post index increment 1 each time goes through "do while"
loop. in other words, first occurrence $_post['tableserver1']
, next 1 $_post['tableserver2']
, etc. loops 6 times , stops.
i have tried using variables index, trying them increment. found example in php manual http://php.net/manual/en/language.operators.increment.php increments number @ end of string, i'm not having luck getting work inside $_post
index.
this section of code creates set of 6 select lists contain names database. trying select lists populate $_post
value if set, other wise zero.
here code:
<?php $x = 1; { ?> <blockquote> <p><?php echo $x . "."; ?> <select name="tableserver<?php echo $x; ?>" id="tableserver<?php echo $x; ?>"> <option selected value="0" <?php if (!(strcmp(0, '$tableserver.$x'))) { echo "selected=\"selected\""; } ?>>select server</option> <?php { if (strpos($row_getnamesrs['service'], '22') !== false) { ?> <option value="<?php echo $row_getnamesrs['memberid'] ?>" <?php if (!(strcmp($row_getnamesrs['memberid'], '$tableserver.$x'))) { echo "selected=\"selected\""; } ?>><?php echo ucfirst(strtolower($row_getnamesrs['first_name'])) . " " . ucfirst(strtolower($row_getnamesrs['last_name'])) ?></option> <?php } } while ($row_getnamesrs = mysqli_fetch_assoc($getnamesrs)); $rows = mysqli_num_rows($getnamesrs); if ($rows > 0) { mysqli_data_seek($getnamesrs, 0); $row_getnamesrs = mysqli_fetch_assoc($getnamesrs); } ?> </select> </p> </blockquote> <?php $x++; } while ($x <= 6); ?>
$i=0; do{ echo $_post['someval'.$i]; }while(++$i < 6)
Comments
Post a Comment