no puedo cambiarla ya que todo el proyecto trabaja en POO y no puedo cambiarla
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
<?php
require('../fpdf/fpdf.php');
class PDF extends FPDF{
private $conexion;
public function __construct(){
require('conexion.php');
$this->conexion = new conexion();
$this->conexion->conectar();
}
}
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial', '', 10);
$pdf->Image('../assests/img/tienda.gif' , 10 ,8, 10 , 13,'GIF');
$pdf->Cell(18, 10, '', 0);
$pdf->Cell(150, 10, 'Store "Aron Imperial"', 0);
$pdf->SetFont('Arial', '', 9);
$pdf->Cell(50, 10, 'Hoy: '.date('d-m-Y').'', 0);
$pdf->Ln(15);
$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(70, 8, '', 0);
$pdf->Cell(100, 8, 'List product', 0);
$pdf->Ln(23);
$pdf->SetFont('Arial', 'B',8);
$pdf->Cell(15, 8, 'Code', 0);
$pdf->Cell(50, 8, 'Product', 0);
$pdf->Cell(25, 8, 'Price', 0);
$pdf->Cell(25, 8, 'Stock', 0);
$pdf->Ln(8);
$pdf->SetFont('Arial','',8);
$record = $product->query("SELECT * FROM product");
$pdf->Output();
?>
function searchProduct($id,$main=false,$limit=false){
if($main !== false && $limit !== false){
$sql="SELECT * FROM product WHERE code like '%".$id."%' or product like '%".$id."%' ORDER BY idproduct ASC LIMIT $main,$limit";
}else{
$sql="SELECT * FROM product WHERE code like '%".$id."%' or product like '%".$id."%' ORDER BY idproduct";
}
echo $sql;
$this->conexion->conexion->set_charset('utf8');
$result=$this->conexion->conexion->query($sql);
$array = array();
while($record = $result->fetch_array(MYSQL_NUM)){
$array[] = $record;
}
return $array;
$this->conexion->cerrar();
}
CREATE TABLE IF NOT EXISTS `product` (
`idproduct` int(11) NOT NULL,
`code` varchar(15) NOT NULL,
`product` varchar(50) NOT NULL,
`price` decimal(9,2) NOT NULL,
`stock` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `product`
--
INSERT INTO `product` (`idproduct`, `code`, `product`, `price`, `stock`) VALUES
(1, 'MG01', 'IPHONE 4S', '5000.00', 6),
(2, 'TCL01', 'IMAC', '5000.00', 6),
(3, 'ILK059', 'SAMSUNG', '5000.00', 6),
(4, '4520', 'HAWEI', '5000.00', 6),
(5, 'A081', 'SNOWBOARD', '5000.00', 6),
(6, 'MSD01', 'SKYBOARD', '5000.00', 6),
(7, 'AUR01', 'SADDS', '5000.00', 6),
(8, 'SA-205', 'CCD', '5000.00', 6),
(9, 'KB-1830', 'USB', '5000.00', 6),
(10, 'MGa01', 'MOVIES', '5000.00', 6),
(11, 'PAS48', 'KNM', '5000.00', 6),
(12, 'OE86Z', 'PJAGDS', '5000.00', 6),
(13, 'HVMHFV', 'ASSAD', '5000.00', 6),
(14, 'AFDD', 'CXVVXC', '5000.00', 6),
(15, 'DASFSDFD', 'XCXCV', '5000.00', 6);
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `purchase`
--
CREATE TABLE IF NOT EXISTS `purchase` (
`idpurchase` int(11) NOT NULL,
`user_iduser` int(11) NOT NULL,
`user_typeuser_idtypeuser` int(11) NOT NULL,
`product_idproduct` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `purchase`
--
INSERT INTO `purchase` (`idpurchase`, `user_iduser`, `user_typeuser_idtypeuser`, `product_idproduct`) VALUES
(1, 1, 1, 10),
(2, 2, 2, 10);
ADD CONSTRAINT `fk_purchase_product1` FOREIGN KEY (`product_idproduct`) REFERENCES `product` (`idproduct`) ON DELETE NO ACTION ON UPDATE NO ACTION,
<?php
require_once('../Models/user.php');
$boton=$_POST['boton'];
switch ($boton) {
case 'cerrar':
session_start();
session_destroy();
break;
case 'login':
$username = $_POST['username'];
$password = $_POST['password'];
$ins = new user();
$array=$ins->identification($username,$password);
if ($array[0]==0)
{
echo '0';
}
else
{
session_start();
$_SESSION['login']='YES';
$_SESSION['name']=$array[1];
}
break;
case 'show_product':
$instancia = new product();
echo $instancia->show_product();
break;
case 'delete_product':
$code = $_POST['code'];
$delete = new product();
if($delete->del($code)){
echo "success";
}
else{
echo "there is something wrong";
}
break;
}
?>
<?php
class user
{
private $conexion;
public function __construct()
{
require_once('conexion.php');
$this->conexion= new conexion();
$this->conexion->conectar();
}
function identification($username,$password){
$pass=md5(sha1($password));
$sql="SELECT * FROM users WHERE username ='$username' && password ='$pass'";
$record = $this->conexion->conexion->query($sql);
if ($record->num_rows > 0) {
$row=$record->fetch_array();
}
else{
$row[0]=0;
}
return $row;
$this->conexion->cerrar();
}
}
?>
<html>
<head>
<title>form</title>
</head>
<body>
<table>
<thead>
<tr>
<th>nombre:</th>
<th>cantidad:</th>
<th>precio:</th>
</tr>
<tr>
<th><input type="text" id="name" placeholder="name"/></th>
<th><input type="text" id="quantity" placeholder="quantity"/></th>
<th><input type="text" id="price" placeholder="price"/></th>
<th><input type="button" id="btn" value="add"/></th>
</tr>
</thead>
<tbody id="data_table">
</tbody>
</table>
<script type="text/javascript">
window.onload = function(){
byId('btn').onclick = function(){
var data = {
name: byId('name').value,
quantity: byId('quantity').value,
price: byId('price').value
};
for(i=0;i<byTag(document,'input').length;i++){
document.getElementById("data_table").innerHTML += "<tr><td>"+data['name']+"</td><td>"+data['quantity']+"</td><td>"+data['price']+"</td></tr>";
}
console.log(arguments);
}
}
</script>
</body>
</html>