Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
All values in array into database?

How would i put the $newd values into the database. The way I'm doing it now just puts one value in. I want all values.

<?php
$checked = $_POST['options'];
for($i=0; $i < count($checked); $i++){
    $newd = "" . $checked[$i] . ",";
}   
    if(isset($_POST['loginbtn'])){
        if(!empty($order)){

if($money){
    //making the sql command
    $sql = "INSERT INTO `orders`(`order`,`date`,`time`,`timepass`,`money`,`corder`,`cancel`,`category`) VALUES ('$order','$date','$timenow','$time','$money','$corder','$cancel','$newd')";

    //querying the sql
    $query = mysqli_query($db,$sql);

    $lastid = mysqli_insert_id($db);

    $twosql = "INSERT INTO `comments`(`order_id`, `comment`,`user`,`time`,`timepass`) VALUES ('$lastid','$comment','$username','$timenow','$time')";
    $twoquery = mysqli_query($db,$twosql);

    header("Location: moneyorder.php"); 

}
?>
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You need a dot here, you are not concatenating the new values :)

$newd .=
over 4 years ago · Santiago Trujillo Report

0

You have to define first $newd variable on top else it will give error but please do the things as suggested by Alex Howansky in comment

$checked = $_POST['options'];
    $newd = '';
    for($i=0; $i < count($checked); $i++){
        $newd .= "" . $checked[$i] . ",";
    } 
$newd = rtrim($newd, ',');

   // OR you can use

    $newd = implode(",", $checked );
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!