-
Notifications
You must be signed in to change notification settings - Fork 0
/
guardaal.php
27 lines (25 loc) · 934 Bytes
/
guardaal.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
header ('Content-type: text/html; charset=utf-8');
$con=mysqli_connect("localhost","root","","orden");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"SET NAMES 'utf8'");
$alimento = mysqli_query($con,"SELECT * FROM alimento WHERE idAlimento=$_GET[ida]");
$raw = mysqli_fetch_array($alimento);
echo $cad = $raw['Nombre']." ".$_GET['alim'];
$result = mysqli_query($con,"SELECT * FROM imprimir WHERE alimentos='$cad' AND idOrden=$_GET[ido]");
if (mysqli_num_rows($result) == 1){
$row = mysqli_fetch_array($result);
$cant= $row['cant']+$_GET['cant'];
echo $sql = "UPDATE imprimir SET cant=$cant WHERE alimentos='$cad' AND idOrden=$_GET[ido]";
}else{
echo $sql = "INSERT INTO imprimir VALUES ($_GET[ido],'$cad',$_GET[cant])";
}
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "";