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

  • Home
  • SEARCH
  • 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 8940229
In Process

The Archive Base Latest Questions

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

I have a form in a php website to edit table data from a

  • 0

I have a form in a php website to edit table data from a dynamic table, it displays correctly but I’m not sure if I’m passing the data correctly or how to access it.

editMenu()

$query = "SELECT * FROM attendance";
$result = mysql_query($query);

print("<b>Edit the details</b><br>");

print("<form method=\"POST\" action=\"editAttendance.php\" >");
print("<table>");
print("<tr>");
for($i = 0; $i < mysql_num_fields($result); $i++) {
    $field_info = mysql_fetch_field($result, $i);
    print("<th>" . $field_info->name . "</th>");
}

while($row = mysql_fetch_row($result)) {
    print("<tr>");
    foreach($row as $_column) {
    print("<td>");
    print("<input type='text' name='{$_column}' size=15 value='{$_column}'>");
    print("</td>");            
    }
print("</tr>");
}  

print("</table>");

print("<input type='submit' value='Edit'>");
print("<input type='button' value='Cancel' onclick=\"location.href='raidAttendance.php'\">");

print("</form>");

mysql_free_result($result);

the editAttendance.php looks like this:

<?php

@mysql_connect("localhost", "root", "vertrigo");
@mysql_select_db("test");

    $b = 0;
    $query = array();
    $result = mysql_query("SELECT * FROM attendance");

    //get all the column names, works
    for ($i = 0; $i < mysql_num_fields($result); $i++) {
        $vars[$i] = mysql_field_name($result,$b);
        $b++;
    }

    //get all the data, stuck here

?>

I know how to fetch the data of a form when it has a set size, but it’s my first time working on a dynamic one, and I can’t make heads or tails of it.

The thing i want to get is an mysql update statement for the whole table, something like:

$query = ""; //all the data from the table
$result = mysql_query("UPDATE attendance SET $query");

The attendance table looks like this and has about 15-18 rows:

id | name | strikes | date1 |date2 | date..

----------------------------------------------
1 | name1 | number | 21/10/2012 | 27/10/2012 | ..

2 | ..
  • 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:59:22+00:00Added an answer on June 15, 2026 at 10:59 am

    When you post the data the format is $_POST[‘field_name’] = ‘value’ in the backend. Do a loop to make the query.

    $query = '';
    
    // Generate the query string
    foreach ($_POST as $field => $value) {
        $query .= $field .' = ' .$value .', ';
    }
    
    $query = substr($query, 0, -2); // Remove the last comma and space
    
    $query .= ' where someField = someValue'; // add condition to the update statment
    

    Then you can execute:

    $result = mysql_query("UPDATE attendance SET $query");
    

    Sorry for my english.

    I hope been helpful.

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

Sidebar

Related Questions

[edit] We're collecting credit application data from users on a web form. I have
I have an php website with login form and I want every visitors can
I have a contact form made with php on my website. The problem is
I have a PHP contact form on my website. I have been using it
I am making an form on my website but I have an problem with
I will have to send mails from a php website via smtp. The smtp
I have a standard select box in my php form for my website containing
I am making a php page that retrieves data from a database table and
I have a form (signup.php) that pops up in a nyroModal window when I
What I have so far: I have a form in PHP that contain the

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.