|
102
|
Programación / PHP / php variable indefinida
|
en: 22 Enero 2016, 00:48 am
|
hola buenas tardes en mi proyecto instale una libreria para hacer pdfs con php pero al momento de querer declarar la variable me dice variable indefinida <?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(); ?>
los errores Notice: Undefined variable: product in C:\xampp\htdocs\store\fpdf\list_product.php on line 32 Fatal error: Call to a member function query() on null in C:\xampp\htdocs\store\fpdf\list_product.php on line 32
|
|
|
104
|
Programación / PHP / ayuda con una consulta en php ya que rediseñe mi base de datos
|
en: 14 Enero 2016, 03:31 am
|
cuando tenia mis tablas separadas si me agarra va bien pero al cambiarla por tablas relacionadas foreigns key , ya no me muestra mi tabla de mis produtos 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); while($record = $result->fetch_array(MYSQL_NUM)){ $array[] = $record; } return $array; $this->conexion->cerrar(); }
mis tablas son estas 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,
|
|
|
106
|
Programación / PHP / ayuda multi ususario
|
en: 2 Diciembre 2015, 03:07 am
|
como puediera hacer un multi usario como me estructura que tengo necesito hacer un login de multi usario para poder hacer otra cosa pero me pudiera ayudar hacer una basica ?? archivo user <?php require_once('../Models/user.php'); $boton=$_POST['boton']; switch ($boton) { case 'cerrar': 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['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; } ?>
usario_model.php <?php class user { private $conexion; public function __construct() { require_once('conexion.php'); $this->conexion= new conexion(); $this->conexion->conectar(); } function identification($username,$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(); } } ?>
|
|
|
107
|
Programación / Desarrollo Web / tabla dinamica en JS puro sin frameworks
|
en: 25 Octubre 2015, 22:01 pm
|
como puedo hacer mi codigo hacerlo dinamico , como lo hago mediante un solo for cada ves que le doy click se vayan agregando <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> <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); } }
|
|
|
|
|
|
|