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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:09:50+00:00 2026-05-25T13:09:50+00:00

I have an application where I need to take the items from a list

  • 0

I have an application where I need to take the items from a list checkbox’s and parse them into my database. Currently I am gathering them into an array by looping through the options and placing a checkbox before each option and making the name example[] in each input. The question is how can I send that array to jquery and then to a php parse file so that it will be recorded in the database as a list deliminated by a comma so that I can call that list out into another field on the website?

So this is what I have, but it is not working

$chart_query = mysql_query("SELECT id, title FROM songs WHERE team_name='$team_name' ORDER BY title ASC");
while($row = mysql_fetch_array($chart_query)){
    $song_id = $row['id'];
    $song_title = $row['title'];

    $song_chart .= '<div align="left" class="song_links"><input class="allcharts" type="checkbox" name="charts[]" value="'.$song_title.'" />&ndash;<a href="http://' . $dyn_www . '/template.php?id='.$song_id.'" style="color:white; text-decoration:none; margin-left:5px;">'.$song_title.'</a></div>';
}

The jquery…

function post_song_list(){
    var allcharts = $(".allcharts").each().val();
    var team_name = $("#team_name").val();
    var list_date = $("#list_date").val();

    if (allcharts = ""){
        alert("You must select at least one song");
    }else{
        $.post("scripts/post_song_list.php", {allcharts: allcharts, team_name: team_name, list_date: list_date}, function(data){
            $(".allcharts").val("");
            $("#team_name").val("#team_name");
            $("#list_date").val("");
        });
    }
}

The php parse…

if(isset($_POST['team_name']) != '' && isset($_POST['list_date']) != '' && isset($_POST['charts']) != ''){
    if(isset($_POST['team_name'])){
        $team_name = $_POST['team_name'];
             $team_name = stripslashes($team_name);
             $team_name = strip_tags($team_name);
             $team_name = mysql_real_escape_string($team_name);
             $team_name = str_replace("'", "&#39;", $team_name);
    }
    $sql = mysql_query("SELECT admin_id FROM myTeams WHERE team_name=$team_name");
    while($row = mysql_fetch_assoc($sql)){
        $admin_id=$row['admin_id'];
        if(isset($_SESSION['idx']) != $admin_id) {
            $msgToUser = '<br /><br /><font color="#FF0000">Only Team Administrators can do that!</font><p><a href="register.php">Join Here</a></p>';
            include_once '../msgToUser.php'; 
            exit(); 
        }
    }
    if(isset($_POST['list_date']))
    $list_date = $_POST['list_date'];
             $list_date = stripslashes($list_date);
             $list_date = strip_tags($list_date);
             $list_date = mysql_real_escape_string($list_date);
             $list_date = str_replace("'", "&#39;", $list_date);
             $list_date = "".$list_date."";
    }

    if(isset($_POST['charts']) != ""){ 
    $checkboxes = isset($_POST['charts']) ? (array)$_POST['charts'] : array();
    $charts = implode('<br />', $checkboxes);
        $charts = stripslashes($charts);
        $charts = strip_tags($charts);
        $charts = mysql_real_escape_string($charts);
        $charts = str_replace("'", "&#39;", $charts);

    $sql_charts = mysql_query("INSERT INTO list (date, team_name, song_list) VALUES ('$list_date','$team_name','$charts')") or die (mysql_error());
    echo "<span>List Uploaded</span>";
}

Can someone tell me where I am going wrong? It will not go to the parse file.

  • 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-05-25T13:09:51+00:00Added an answer on May 25, 2026 at 1:09 pm

    Not covering the jquery part, but assuming it was a normal form submission:

    HTML:

    <input type="checkbox" name="cb[]" value="1" />
    <input type="checkbox" name="cb[]" value="2" />
    etc...
    

    PHP:

    <?php
    
    $checkboxes = isset($_POST['cb']) ? (array)$_POST['cb'] : array();
    
    $string = implode(',', $checkboxes);
    $ready_for_sql = mysql_real_escape_string($string);
    
    $sql = "INSERT INTO yourtable (checkboxfield) VALUES ('$ready_for_sql')";
    $result = mysql_query($sql) or die(mysql_error());
    

    of course, depending on how you’re going to be using those values, you may NOT want to store them as a comma-separated list. If you need to refer to individual values in that list, you’d be better off using a child table to store each value separately.

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

Sidebar

Related Questions

Currently I have an application that takes information from a SQLite database and puts
I have an application where I need to INSERT an auto_increment value from a
I have an application, which need to do some validation on the database end.
In my application, users have a list of items that they can put in
In my Titanium application I need to take pictures from camera, while invoking the
I have two application that need to talk to each other. App1 needs to
I have an application I need to analyze. I have the source code here.
I have this application that need to do some things in protected paths (like
I have an application where I need the user to upload a photo. After
I have a java application I need to pass some info to a C++

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.