Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

179
Vistas
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 Respuestas
Responde la pregunta

0

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

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

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda