Saving 'Looping Input Tag' Values Into Table As Many Records

I am just starting to make a web-based diagnose system for my study task, and I need to loop the input tag on my input form. I add this code manually on my add page tbl_gejalapasienadd.php which is generated by phpmaker,

?php
$no = 0;
$rs = Execute(“SELECT nm_gejala FROM tbl_gejala”); // I need to loop as much as it’s record
if ($rs->RecordCount() >0) {
$rs->MoveFirst();
while (!$rs->EOF) {
$no++;?>

// I place the input form code here, and for each input tag i have added unique id by add ‘echo $no’ on it’s input id.

<?php $rs->MoveNext(); } $rs->Close(); } else { echo "No Record Found."; } ?>

The input tag is looping just like what i want, but when I finish do the input and click submit button, it just save the first record to the table…
Is this because my poor code above? Or I have to add loop on it’s insert query too (but i don’t know where to find it) (T-T)?
Or you have better solution for me? Please be patient on me, I am a newbie… Thanks for your attention

Coders wrote:

// I place the input form code here, and for each input tag i have added unique id
by add ‘echo $no’ on it’s input id.

Please post your code for more discussion.

Here is the code:

<?php $no = 0; $rs = Execute("SELECT nm_gejala FROM tbl_gejala"); if ($rs->RecordCount() >0) { $rs->MoveFirst(); while (!$rs->EOF) { $no++;?> <?php if ($Page->CheckToken) { ?> " value="<?php echo $Page->Token ?>"> <?php } ?> <?php if ($tbl_gejalapasien->getCurrentMasterTable() == "tbl_gejala") { ?> " value="tbl_gejala"> <?php } ?> <?php if ($tbl_gejalapasien->getCurrentMasterTable() == "tbl_user") { ?> " value="tbl_user"> <?php } ?>
<?php if ($tbl_gejalapasien_add->id_gejala->Visible) { // id_gejala ?>
<?php echo $tbl_gejalapasien_add->id_gejala->caption() ?><?php echo $tbl_gejalapasien_add->id_gejala->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?>
id_gejala->cellAttributes() ?>> <?php if ($tbl_gejalapasien_add->id_gejala->getSessionValue() != "") { ?> id_gejala->viewAttributes() ?>>id_gejala->ViewValue)) ?>"> <?php } else { ?>
id_gejala->editAttributes() ?>> <?php echo $tbl_gejalapasien_add->id_gejala->selectOptionListHtml("x_id_gejala") ?>
<?php echo $tbl_gejalapasien_add->id_gejala->Lookup->getParamTag($tbl_gejalapasien_add, "p_x_id_gejala") ?>
<?php } ?> <?php echo $tbl_gejalapasien_add->id_gejala->CustomMsg ?>
<?php } ?> <?php if ($tbl_gejalapasien_add->t_gp->Visible) { // t_gp ?>
<?php echo $tbl_gejalapasien_add->t_gp->caption() ?><?php echo $tbl_gejalapasien_add->t_gp->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?>
t_gp->cellAttributes() ?>> t_gp->EditAttributes() ?>> t_gp->EditAttributes() ?>> <?php echo $tbl_gejalapasien_add->t_gp->CustomMsg ?>
<?php } ?> <?php if ($tbl_gejalapasien_add->i_gp->Visible) { // i_gp ?>
<?php echo $tbl_gejalapasien_add->i_gp->caption() ?><?php echo $tbl_gejalapasien_add->i_gp->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?>
i_gp->cellAttributes() ?>> i_gp->EditAttributes() ?>> i_gp->EditAttributes() ?>> <?php echo $tbl_gejalapasien_add->i_gp->CustomMsg ?>
<?php } ?> <?php if ($tbl_gejalapasien_add->f_gp->Visible) { // f_gp ?>
<?php echo $tbl_gejalapasien_add->f_gp->caption() ?><?php echo $tbl_gejalapasien_add->f_gp->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?>
f_gp->cellAttributes() ?>> f_gp->EditAttributes() ?>> f_gp->EditAttributes() ?>> <?php echo $tbl_gejalapasien_add->f_gp->CustomMsg ?>
<?php } ?>
<?php if (strval($tbl_gejalapasien_add->id_user->getSessionValue()) != "") { ?> <?php } ?> <?php if (!$tbl_gejalapasien_add->IsModal) { ?>
<?php echo $Language->phrase("AddBtn") ?> <?php echo $Language->phrase("CancelBtn") ?>
<?php } ?>



<?php $rs->MoveNext(); } $rs->Close(); } else { echo "No Record Found."; } ?>

Double check your code. Make sure you have already put the <form … > and tag outside the looping block, so that you should have only one form instead of several forms.

mobhar wrote:

Double check your code. Make sure you have already put the <form … > and

tag outside the looping block, so that you should have only one form instead of several forms.



I’ve tried it before but it makes the page doesn’t stop to load, is there any mistake else? Thanks…

Coders wrote:

is there any mistake else?

Press [F12] from your browser to check the error from Console section. In addition, enable the Debug mode from “Tools” → “Advanced Settings” and then re-generate at least ewcfg.php (assume you’re using v2020).

Make sure also the code to display the button has been put outside the looping block.

Thanks, The problem solved by following your advise and adding unique id at input ‘name’ too.

Now I want to put … inside the looping using lookup table, but the values doesn’t come out.
Here is the code for select tag inside the looping,

<?php if ($tbl_gejalaahli_add->id_gejala->Visible) { // id_gejala ?>
<?php echo $tbl_gejalaahli_add->id_gejala->caption() ?><?php echo $tbl_gejalaahli_add->id_gejala->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?>
id_gejala->cellAttributes() ?>> <?php if ($tbl_gejalaahli_add->id_gejala->getSessionValue() != "") { ?> id_gejala->viewAttributes() ?>> <?php } else { ?>
id_gejala->editAttributes() ?>> <?php echo $tbl_gejalaahli_add->id_gejala->selectOptionListHtml("x_id_gejala") ?>
<?php echo $tbl_gejalaahli_add->id_gejala->Lookup->getParamTag($tbl_gejalaahli_add, "p_x_id_gejala") ?>
<?php } ?> <?php echo $tbl_gejalaahli_add->id_gejala->CustomMsg ?>
<?php } ?> <?php if ($tbl_gejalaahli_add->id_status->Visible) { // id_status ?>
<?php echo $tbl_gejalaahli_add->id_status->caption() ?><?php echo $tbl_gejalaahli_add->id_status->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?>
id_status->cellAttributes() ?>> <?php if ($tbl_gejalaahli_add->id_status->getSessionValue() != "") { ?> id_status->viewAttributes() ?>> <?php } else { ?>
id_status->editAttributes() ?>> <?php echo $tbl_gejalaahli_add->id_status->selectOptionListHtml("x_id_status") ?>
<?php echo $tbl_gejalaahli_add->id_status->Lookup->getParamTag($tbl_gejalaahli_add, "p_x_id_status") ?>
<?php } ?> <?php echo $tbl_gejalaahli_add->id_status->CustomMsg ?>
<?php } ?>