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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:23:54+00:00 2026-06-18T07:23:54+00:00

I have this code (this is working and pass these variable to another file)

  • 0

I have this code (this is working and pass these variable to another file)

            var month = "<?php echo openedMonthbid();?>";
    var user = "<?php echo $_SESSION['member_id'];?>";
    var day = new Array();


    $(':checkbox:checked').each(function(i){
    day.push('`' + $(this).val() + '`');  });
    var count = day.length;

                            $.ajax({
                            type: "POST",
                            url: "sendBidding.php",
                            data : "user="+user+"&days="+day+"&month="+month+"&number=",
                            dataType: "json",

sendBidding.php

$month = $_POST['month'];
$user = $_POST['user'];
$days = $_POST['days'];
$count = $_POST['count'];//if a check 3 values I get '3'


      mysql_query("INSERT INTO $month ($days) VALUES ('1','1','1')");


    $result = true;

    echo json_encode(array("success"=>$result,
                               "datas" => $data,
                                "mon"=>$month));

I would like to add as many values (‘1’) as the number of days selected. How can I change VALUES (‘1′,’1′,’1’) ?

  • 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-18T07:23:55+00:00Added an answer on June 18, 2026 at 7:23 am

    Here’s a solution for generating a sequence of identical strings. Use array_fill().

    $month = $_POST['month'];
    $days = $_POST['days'];
    
    // Be sure to whitelist $month and $days before using them in an SQL query!  
    // For example, you could store an associative array keyed by month,
    // containing lists of the day column names.
    $month_table_whitelist = array(
      "month_jan" => array("day1", "day2", "day3", /* etc */),
      "month_feb" => array("day1", "day2", "day3", /* etc */),
      /* etc */
    );
    if (!array_key_exists($month, $month_table_whitelist)) {
      die("Please specify a valid month.");
    }
    if (!array_search($days, $month_table_whitelist[$month])) {
      die("Please specify a valid day of month.");
    }
    
    $count = $_POST['count'];//if a check 3 values I get '3'
    
    $tuples = array_fill(1, $count, "('1')");
    
    $status = mysql_query("INSERT INTO $month ($days) VALUES ".implode(",", $tuples));
    if ($status === false) {
      die(mysql_error());
    }
    

    PS: Your query is vulnerable to SQL injection, by interpolating unsafe values $month and $days directly into your query. You should use a whitelist method to ensure these inputs match real table and column names in your database, don’t just trust the user input.

    PPS: You should know that you’re using the ext/mysql functions, but these are deprecated. If this is a new application, you should start using mysqli or PDO before investing more time into using the deprecated API.

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

Sidebar

Related Questions

I have this code working in C#: var request = (HttpWebRequest)WebRequest.Create(https://x.com/service); request.Method = GET;
I used to have this code working with my Tomcat server: HttpRequestBase targetRequest =
this seems to be weird but it really happened. I have this code working
I have this JQuery code working however I need to know whether how to
I have this working code, but now i need to be able to change
i have this code and its working but i want it to return dailyTotals
i have this code $(function() { $('#ans_vote a span').click(function(){alert('working');return false;});}); and this html <div
Hi Javascript gurus, I have this Javascript code which is working fine on Firefox
As a beginner in Ocaml, I have this current working code: ... let ch_in
I have this (working) CPU code: #define NF 3 int ND; typedef double (*POT)(double

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.