How popular a select

Asked

Viewed 107 times

0

I’d like to know how popular a select html with jquery, because I need to pull from the database, however, my file is . html and I am working with routes so have the views that are the files . html and routes.

This is the View

<div class="container">
	<div class="row">
        <form action="" method="post">
            <div class="form-row align-items-center">
                <div class="search-products">
                  <h1 class="title-products">Escolha sua Peça:</h1>
                    <select name="desmarca" id="desmarca" class="input-text" required="required">
                        <option disabled="disabled" selected="selected" value="">Marca</option>
                        {loop="$marca"}
                        <option value="{$value}">{$value.desmarca}</option>
                        {/loop}
                    </select>

                <button class="buscar-produtos" type="submit">Buscar</button>
            </div>
        </form>
		</div>
	</div>
</div>

Here is the PHP class

<?php 

namespace Hcode\Model;

use \Hcode\DB\Sql;
use \Hcode\Model;
use \Hcode\Mailer;


class Marcas extends Model {

	public static function listAll()
	{

		$sql = new Sql();

		return $sql->select("SELECT * FROM tb_marcas ORDER BY desmarca");

	}

	public static function checkList($list)
	{

		foreach ($list as &$row) {
			
			$m = new Marcas();
			$m->setData($row);
			$m = $m->getValues();

		}

		return $list;

	}
	public function save()
	{
		$sql = new Sql();

		$results = $sql->select("CALL sp_marcas_save(:idmarca, :desmarca)", array(
			":idmarca"=>$this->getidmarca(),
			":desmarca"=>$this->getdesmarca()
		));

		$this->setData($results[0]);


	}
	public function get($idmarcas)
	{

		$sql = new Sql();

		$results = $sql->select("SELECT * FROM tb_marcas WHERE idmarca = :idmarca", [
			':idmarca'=>$idmarca
		]);

		$this->setData($results[0]);

	}


	
}

 ?>

And here is the route

$app->get('/products', function(){
	$page = new Page();
    
    $marca = Marcas::listAll();

		$page->setTpl("products", [
		    'marcas'=>Marcas::checklist($marca)
		    ]);
		
});

1 answer

0

Hello, Deni.

Try this in html file:

<select name="desmarca" id="desmarca" class="input-text" required="required">
     <option disabled="disabled" selected="selected" value="">Marca</option>
     {loop="$marca"}
          <option value="{$value.idmarca}">{$value.desmarca}</option>
     {/loop}
</select>
  • Thanks man, I already got it, now I’m with another problem kkk I’ll edit my post and if you can help me thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.