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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:58:34+00:00 2026-06-18T06:58:34+00:00

I have a php code where data from my database are fetched in an

  • 0

I have a php code where data from my database are fetched in an array with checkbox corresponding each data . I already have the codes enabling updates to my table (for each data checked):

<?php
include("connect.php");
$user=$_SESSION['username'];
$updated = FALSE;
$submit=FALSE;
if(count($_POST) > 0){

$library = $_POST['library'];
array_map('intval',$library);
$library = implode(',',$library);
mysql_query("UPDATE ES_Students SET library=0") or trigger_error(mysql_error

(),E_USER_ERROR);
mysql_query("UPDATE ES_Students SET library=1 WHERE StudentNO IN ($library)") or        trigger_error

(mysql_error(),E_USER_ERROR);
$submit=TRUE;
$updated=TRUE;
}
?>

My problem is, whenever no checkbox is checked, an error will occur that the library index is undefined and all. I know it’s got something to do with the $count($_POST)>0 but I don’t actually know how to fix this. I tried putting an else-clause to redirect it to another page but it will result to same error. Can anyone tell me what to do??

  • 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-18T06:58:36+00:00Added an answer on June 18, 2026 at 6:58 am

    Use an isset around your post. PHP link

    if( isset($_POST) && count($_POST) > 0){
      ....
    

    If any data is sent at all, even a blank form, isset($_POST) will return true, but with a count($_POST) of 0. So, you could also test for the exact items of the array you’re looking for to be sure it is infact in the $_POST :

    if( isset($_POST) && count($_POST) > 0 && isset($_POST['library'])){
     ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written php code to retrieve data from database to div in webpage.i
I have this php code that grabs binary( blob ) data from the database
Basically i have php code which retrieves data from a database into a table,
i have this simple code to load data from other php page using get
I have written a code for taking JSON data from a PHP and putting
I have this code to display the data retrieved from DB in accounts_view.php :
I have a PHP script that extract valid GeoJSON data from a database. Now
I have php code that returns this from a database, [ { Time: 2012-11-27
i have a php code which selects and shows data from my 'elections' table.
I have a php file which retrieves data from a MySql database and display

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.