i have in php a table with some rows. Each row contains a dataset with an id.
The mission is to skip a field in a database depending on the id. The id is unknown.
i plan to skip the dataset with submit buttons. Also each dataset has one button. The form will send to PHP_SELF and in an function i do the update on the database.
Now the challenge is, to find out, which button ist pressed. It is not possible to run trough a case block, because the ids are between 1 and 99999.
can someone help me. I can rename type, name, id, of the buton. The id are already in the rowset.
Thank you very much!
Frank
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<fieldset><legend>Ihnen zugewiesene Services</legend>
<table width="100%" border="1">
<tr>
<th>Schalter</th>
<th width="100%">Servicename</th>
<th width="50">Status</th>
</tr>
<?php do { ?>
<tr>
<?php if ($row_Recordset1['sendToVoicebox'] == 0) { ?>
<td><input type="submit" name="<?php $row_Recordset1['service_id']; ?>" id="btnOn" value="Voicebox ein" /></td>
<?php } else { ?>
<td><input type="submit" name="<?php $row_Recordset1['service_id']; ?>" id="btnOn" value="Voicebox aus" /></td>
<?php } ?>
<td><?php echo $row_Recordset1['service_id']; ?></td>
<?php if ($row_Recordset1['sendToVoicebox'] == 0) { ?>
<td><img src="images/VoiceboxOff.png" width="64" height="64" alt="pause" /></td>
<?php } else { ?>
<td><img src="images/VoiceboxOn.png" width="64" height="64" alt="pause" /></td>
<?php } ?>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</fieldset>
<input type="hidden" name="MM_update" value="form1" />
<input name="service_id" type="hidden" value="<?php echo $row_Recordset1['service_id']; ?>" />
<?php if ($row_Recordset1['sendToVoicebox'] == 0) { ?>
<input name="update" type="hidden" value="1" />
<?php } else { ?>
<input name="update" type="hidden" value="0" />
<?php } ?>
</form>
how can i catch the id in my function?
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE acdbasis SET userfield_2=%s WHERE service_id=%s",
GetSQLValueString($_POST['update'], "text"),
GetSQLValueString($_REQUEST['submit'], "int"));
You can use array
Although it isn’t very elegant solution I still think it’s better than iterating through $_POST and checking if key is number.