G. srv / srvProductoConsulta.php

1<?php
2
3require_once __DIR__ . "/../lib/php/ejecutaServicio.php";
4require_once __DIR__ . "/bd/productoConsulta.php";
5
6ejecutaServicio(function () {
7 $lista = productoConsulta();
8 $render = "";
9 foreach ($lista as $modelo) {
10 $id = htmlentities($modelo->id);
11 $nombre = htmlentities($modelo->nombre);
12 $precio = htmlentities("$" . number_format($modelo->precio, 2));
13 $existencias = htmlentities(number_format($modelo->existencias, 2));
14 $render .=
15 "<dt>$nombre</dt>
16 <dd>
17 <a href='agrega.html?id=$id'>Agregar al carrito</a>
18 </dd>
19 <dd>
20 <dl>
21 <dt>Precio</dt>
22 <dd>$precio</dd>
23 <dt>Existencias</dt>
24 <dd>$existencias</dd>
25 </dl>
26 </dd>";
27 }
28 return ["lista" => ["innerHTML" => $render]];
29});
30
skip_previous skip_next