-1
I am creating a small cafeteria command system , and I would like to know how to make each new form to display the number of the current where the name commands , so I do not have to enter the number and yes already comes automatic IN PHP I APPRECIATE. The source code
<html>
<head>
<meta charset="utf-8"/>
<title>Peixaria</title>
<style>
.add {
text - decoration: none;
}
</style>
</head>
<body>
<style>
.add,add2{ text-decoration:none;}
#selecionados input,#selecionados2 input{ margin:10px;}
</style>
<h1>Peixaria</h1>
<ul class="menu cf">
<li><a href="secao.php">Início</a></li>
<li><a href="pedidos.php">Pedidos</a></li>
<li><a href="reserva.php">Reserva</a></li>
<li><a href="relatorio.php">Relatório</a></li>
</ul>
<main>
<form>
<header>
<h2>Fazer Pedido</h2>
</header>
<fieldset>
<label>
<span>Comanda:</span>
<input type="text" value="">
</label>
<label>
<span>Mesa:</span>
<input type="text" value="">
</label>
<span>Refeições/Bebidas/Sobremesas:</span>
<div class="pedidos">
<select class="selecionar">
<option selected disabled>Selecione</option>
<option >Costela de Tambaqui sem Espinha</option>
<option >Lombo de Tambaqui Frito sem Espinha</option>
<option >Caldeirada de Tambaqui sem Espinha</option>
<option >Caldeirada de Tucunaré</option>
<option >Peixe no Tucupi com Camarão</option>
<option >Escabeche de Pirarucu</option>
<option >Escabeche de Tambaqui</option>
<option >Escabeche de Tucunaré</option>
<option >Tucunaré Frito</option>
<option >Sardinha Frita</option>
<option >Jaraqui Frito</option>
<option >Pacu Frito</option>
<option >Filé de Pirarucu Frito</option>
<option >Filé de Pirarucu a Milanesa</option>
<option >Guisado de Pirarucu</option>
</select>
<a class="add" href="#">+</a>
<hr>
Selecionados
<hr>
<div class="selecionados">
</div>
</div>
<br>
<div class="pedidos">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select class="selecionar">
<option selected disabled>Selecione</option>
<option >Fanta Laranja 1l</option>
<option >Fanta Laranja 2l</option>
<option >Cola Cola 1l</option>
<option >Cola Cola 2l</option>
<option >Bare 2l</option>
<option >Fanta Uva</option>
<option >Fanta Laranja</option>
<option >Sprit</option>
<option >Cola Cola </option>
<option >Cola Cola zero </option>
<option >Guaraná Antarctica</option>
<option >Guaraná Baré</option>
<option >Suco Goiaba</option>
<option >Suco Manga</option>
<option >Suco Pessego</option>
<option >Suco Uva</option>
<option >Suco Maracujá</option>
<option >Suco Laranja</option>
<option >Suco Caju</option>
<option >Agua Mineral </option>
<option >Agua com Gas </option>
<option >Cerveja em Lata</option>
<option >Limonada Natural</option>
</select>
<a class="add" href="#">+</a>
<hr>
Selecionados
<hr>
<div class="selecionados">
</div>
</div>
</fieldset>
</form>
</main>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$(".add").on('click',function(){
var cont=0;
var holder = $(this).closest('.pedidos');
holder.find(".selecionados input").each(function(){
if($(this).val()==holder.find(".selecionar option:selected").html()){
cont++;
}
});
if(cont>0) {
alert("Este item ja esta adicionado, altere a quantidade se deseja mais..");
} else{
holder.find(".selecionados").append(
"<input disabled type='text' name='pedidos[]' value='" +
holder.find(".selecionar option:selected").html() +
"' ><input type='text' name='quantidade[]' placeholder='quantidade'><br>"
);
}
});
</script>
</body>
</html>
If this is recorded in the database, you can use the id of the last +1 record to set the next command.
– JuniorNunes
Each new request is sent to the database. And when I open a new request I wanted to display the form number where it is written commands , how could I do this in php . would have to put as reply @Juniornunes ?
– allan araujo
This order numbering is daily or always incremental to infinity?
– fernandosavio
is incremental to infinity , type every time I open a request it opens together , as a control even , only it goes pro mysql. how could I display her ?
– allan araujo
Where is the script that generates the command in the database when a new request is made? Which database is being used? What is the structure of your table? This information we cannot guess.
– Filipe Moraes