PHP - limitar un máximo de stock

 
Vista:

limitar un máximo de stock

Publicado por josele (12 intervenciones) el 09/09/2020 19:27:45
Hola tengo esta función que suma +1 a capacidad y quiero limitar a cuando capacidad==maxcapacidad de resultado false.
Gracias


1
2
3
4
5
6
7
8
9
10
else if(isset($_POST['consulta'])){
	$reg_id=$_POST['reg_id'];
 
	$q=mysqli_query($conn, "UPDATE `coches` SET capacidad = capacidad+1 WHERE `reg_id`='$reg_id'");
	if($q){
		echo "true";
	}
	else
		echo "false";
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

limitar un máximo de stock

Publicado por josele (12 intervenciones) el 09/09/2020 20:20:00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
else if(isset($_POST['consulta'])){
	$reg_id=$_POST['reg_id'];
 
$q=mysqli_query($conn, "SELECT * FROM `coches` WHERE `username`='$username' and `status`='true'");
 
$row = mysqli_fetch_array($q);
 
if ($row['max_capacidad']!=$row['capacidad']){
	if(data.capacidad<=data.maxcapacidad){
 
$q=mysqli_query($conn, "UPDATE `coches` SET capacidad = capacidad+1  WHERE `reg_id`='$reg_id'");
		echo "true";
	}
	else
		echo "false";
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar