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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:37:56+00:00 2026-06-15T23:37:56+00:00

So basically what I want to do is to grab the selected checklist element(s)

  • 0

So basically what I want to do is to grab the selected checklist element(s) and send their “name” to the database. I would also like to do the same with the radios. Here is the code:

<?php       
        $user_files_directory = 'uploads/unused_images/'.$_SESSION['user_id'].'/';

        if (file_exists($user_files_directory)) {

        $dir_handle = @opendir($user_files_directory); 

        while ($file = readdir($dir_handle)) { 

        if($file == "." || $file == ".." || $file == "index.php" ) 

        continue; 

            echo "
            <div id=\"image_container\">
                <div id=\"unused_images_selector\">
                    <img src=\"uploads/thumbs/unused_images/".$_SESSION['user_id']."/$file\" alt=\"Test\">
                </div>
                <div id=\"checkbox\">
                        <input type=\"checkbox\" name=\"$file\">
                </div>
            </div>
            "; 
        }
        // Close 
        closedir($dir_handle); 

        } else {
            echo    "<p>
                        You have not uploaded any images.
                    </p>";
        }
    ?>

A post for this exists:

$file = $_POST['file'];

And here is the rest:

function create_new_page($page_name, $album_name, $file, $file1, $file2) {
        $page_name = mysql_real_escape_string(htmlentities($page_name));
        mysql_query("INSERT INTO `pages` VALUES ('', '$album_name', '".$_SESSION['user_id']."', UNIX_TIMESTAMP(), '$page_name', '$file2', '$file3', '$file')");
        return mysql_insert_id();
    }

Everything but the radio/checklist works, any help is greatly appreciated, I know the code may not be the best but that’s because I’ve not done much PHP, just want some working code though so not worried too much right now about issues here and there.

EXTRA: $file is the name of the images that are being placed in the page (it’s a selection area for which images a user would like to use) and so I was hoping that, with using $file it would create the image name in the MYSQL database but it instead writes “array”.

  • 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-15T23:37:57+00:00Added an answer on June 15, 2026 at 11:37 pm

    You have misunderstood the workings of a HTML form and the way to extract it in PHP.
    You are setting the name attribute to the actual file name (which is not “file”) and are trying to extract the POST param with name file. The way to do this would be to name the checkbox file[] (as in an array of files) and set the value attribute to the file name. Your PHP code may remain the same.

    Modify your checkbox code as follows:

    <div id=\"checkbox\">
            <input type=\"checkbox\" name=\"file[]\" value=\"$file\" />
    </div>
    

    Since you already have the following:

    $file = $_POST['file'];
    

    $file will give you an array of file names. You can then process that data as you require.

    EDIT : Since the OP has modified the question.

    You want to store multiple image names into the database so you need to fire multiple INSERT statements. You could probably loop on the $file variable and build your queries.

    Use something on the following lines:

    $mysqli = new mysqli("localhost", "dbuser", "dbpassword", "dbname");
    
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }
    
    foreach ($file as $filename) {
        $query = $mysqli->prepare("INSERT INTO tblImages vcImageName VALUES (?)");
        $query->bind_param("s", $filename);
        $query->execute();
        $query->bind_result($result);
        $query->fetch();
        $query->close();
    }
    
    $mysqli->close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I want to grab an id send via the url (ex. www.website.com/?id=432432) and
I basically want something like: TextView Button Button . . . TextView TextView SeekBar
I basically want the same functionality as facebook, twitter and all those other infinite
I basically want to be able to deploy multiple versions of the same EAR
basically i want to hold a parameter that retrieve value from $.post() call like
Basically, I want to use BeautifulSoup to grab strictly the visible text on a
Basically, i want to write a windows form program like any other webcam's control
Basically I want to be able to specify an xml or 2 like so
So basically what I want to do is grab links to images within a
Basically, i want to write a windows form program like any other webcam's control

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.