Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8938177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:34:05+00:00 2026-06-15T10:34:05+00:00

i have in php a table with some rows. Each row contains a dataset

  • 0

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"));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:34:06+00:00Added an answer on June 15, 2026 at 10:34 am

    You can use array

    <?php if ($row_Recordset1['sendToVoicebox'] == 0) { ?>
    <td><input type="submit" name="button[<?php echo $row_Recordset1['service_id']; ?>]" id="btnOn" value="Voicebox ein" /></td>
    <?php } else { ?>
    <td><input type="submit" name="button[<?php echo $row_Recordset1['service_id']; ?>]" id="btnOn" value="Voicebox aus" /></td>
    <?php } ?>
    
    <?php
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
    $service_id = array_keys($_POST["button"]);
    $service_id = $service_id[0]; //older php versions don't allow direct function...)[key]
    $updateSQL = sprintf("UPDATE acdbasis SET userfield_2=%s WHERE service_id=%s",
                       GetSQLValueString($_POST['update'], "text"),
                       GetSQLValueString($service_id, "int"));
    

    Although it isn’t very elegant solution I still think it’s better than iterating through $_POST and checking if key is number.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with some rows, each row has a unique key. When
Trying to have my PHP script return some SQL table queries. Here's my script
I have a php table and i want the ability to delete rows of
I have a table generated from some PHP code that lists a SMALL amount
I have a table that get its rows from a MYSQL database <table id=table1>
Let's say I have 10 books, each book has assigned some categories (ex. :php,
I have some PHP code that generates dynamic tables of data on the fly.
I have created a php table like so: echo <table border = '0' cellpadding
I have a php script that backup my table in .sql format and I
I have a PHP/MySQL query that returns to an HTML table, and I'm stuck

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.