php select form with fields from another table without being connected

0
CREATE TABLE 'pedidos' (
  'pk' int(3) UNSIGNED NOT NULL,
  'residentes' varchar(50) COLLATE NOT NULL,
  'dniFamiliar' varchar(10) COLLATE DEFAULT NULL,
  'servicios' int(3) NOT NULL,
  'fecha' datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;

CREATE TABLE 'servicios' (
  'codServicio' int(3) NOT NULL,
  'concepto' varchar(50) NOT NULL,
  'precio' float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1_spanish_ci;

I have these two tables, where orders are to make invoices. everything with php

I have to make a form in php with a select that I take the fields of the table services to do the invoicing and save it at the same time in a database. they ask me to do it with PDO oriented to objects, but I have no idea what that is, because I just did a 300-hour work stoppage and I have not even seen it and in practice they ask me for this, which does not sound to me. we only saw the basics of the basics The most I have come to do is this Concept:

<select>
<?php
    include("conexion.php");
    // Realizamos la consulta para extraer los datos
    $query = $mysqli -> query ("SELECT * FROM servicios");
    while ($valores = mysqli_fetch_array($query)) {
        // En esta sección estamos llenando el select con datos extraidos de una base de datos.
        echo '<option value="'.$valores[codServicio].'">'.$valores[concepto].'</option>';
    }
?>
</select>

but it does not load anything to me, it does not leave error, nothing

    
asked by elena 21.11.2018 в 11:54
source

1 answer

-1

Concept:                                                                                                            $ result = $ mysqli - > query ("SELECT * FROM services");                                          if ($ result-> num_rows > 0) {                                                 $ strHTML. = 'codService';                                                 $ strHTML. = '';                                                     $ strHTML. = 'Selection:';                                             while ($ values = $ result-> & fetch_array (MYSQLI_ASSOC)) {                                                     $ strHTML. = ''. $ values ['codService']. '';                                             }                                                 $ strHTML. = '';                                             echo $ strHTML;                                         } else {                                             $ arrError = array ("message" => "No records were found")

                                        }                                     } else {                                         $ arrError = array ("message" => "The connection to the database can not be established. Check connection.php")

                                    }                           

Now I'm in this, and still nothing comes out

    
answered by 21.11.2018 в 12:08