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 8190901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:46:57+00:00 2026-06-07T03:46:57+00:00

I am new to PHP. So i first apologize if i am using dumb

  • 0

I am new to PHP. So i first apologize if i am using dumb strategy. I am working on PHP site.
my page queries data from MySql and shows in html table along with me checkboxes. User can Delete any data using check boxes and button. this all is done using javascript. Here is my code to delete data from html table

<script type="text/javascript">
function deleteRow() {
        try {
            var table = document.getElementById("Categories");
        var rowCount = table.rows.length;



        for(var i=0; i<rowCount; i++) {
            var row = table.rows[i];
            var chkbox = row.cells[0].childNodes[0];
            if(null != chkbox && true == chkbox.checked) {
                table.deleteRow(i);
                rowCount--;
                i--;
            }


        }
        }catch(e) {
            alert(e);
        }
    }

</script>

on clicking Save button MySql update query should run to save all changes made to page.
I know this can be done by PHP. but problem here is how i can get data from html in php to run the query??
if any one can point me to right direction, i will be thankful to you.

Thanks.

  • 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-07T03:46:59+00:00Added an answer on June 7, 2026 at 3:46 am

    You can make a form where you’ll have checkboxes like: <input type="checkbox" name="m_Name[]" value="id_of_element">. When you submit this form on server-side you can do:

    foreach ($_POST['m_Name'] as $id){
        $query = 'DELETE FROM table WHERE id='.$id;
        //execute query with mysqli_*, PDO or mysql_*; NOTE: if you are not doing educational project don't use last one.
    }
    

    But better approach will be:

    $query = 'DELETE FROM table WHERE id IN (';
    $in = '';
    
    foreach ($_POST['m_Name'] as $id)
        $in .= $id.',';
    
    $in = substr($in, 0, strlen($in)-1).')'; // removes extra "," at the end.
    $query .= $in;
    //run the query.
    

    The last one wil execute only one query to delete notes so it’s better for performance. But the way I’ve created query seems ugly to me but I am very tired to thing about improvements. 🙂

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

Sidebar

Related Questions

I have a new php page and I'm using wordpress for my website. From
New to PHP and MySQL, have heard amazing things about this website from Leo
first off I am fairly new to php like 3 weeks working with it,
I am building my first PHP/MySQL site and i would like to return search
I'm pretty new to PHP and I'm currently working on my first PHP website.
I'm very new in php. So i realize from my first steps is this
I'm new to PHP first of all .. My question is once I got
I'm new to learning php and in one of my first programs I wanted
I am trying to use a PHP form (new.php) to update 2 MySQL tables
I'm extremely new to PHP and my first project was developing a comment system.

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.