L7 final ------------------------------------------------------------------------ antet.php ------------------------------------------------------------------------
Inceput | Inapoi |
Magazin online Firma X SRL------------------------------------------------------------------------ subsol.php ------------------------------------------------------------------------ |
Alegeti categoria:
Nr. | Categorie | Total Produse |
Total produse:
------------------------------------------------------------------------ admin_lista.php ------------------------------------------------------------------------ ?php require('antet.php');?>Nr. | Produs | Descriere | Pret | Cantitate | Actiuni |
modifica | |||||
- | Produs nou | adauga |
Alegeti categoria! ------------------------------------------------------------------------ admin_formular.php ------------------------------------------------------------------------ Produsul \"".$_POST["prod"]."\" modificat in categoria \"".$_POST['categ']."\"!
"; } else {//NU exista acest produs INSERT $query = "INSERT INTO `produse` (`nume`, `detalii`, `pret`, `cant`, `id_categ`) VALUES ('".$_POST["prod"]."', '".$_POST["descriere"]."', ".$_POST['pret'].", ".$_POST['cantitate'].", (SELECT `id_categ` FROM categorii WHERE `nume` = '".$_POST['categ']."') )"; echo $query;//util in perioada de testare $result = mysqli_query($conex, $query); $record=mysqli_insert_id($conex);//obtinerea id-ului nou echo "Produsul \"".$_POST["prod"]."\" adaugat in categoria \"".$_POST['categ']."\"! Are id = ".$record."
"; } $produse[$_POST['categ']][$_POST['prod']]=array("descr" => $_POST['descriere'], "pret" => $_POST['pret'], "cant" => $_POST['cantitate']); ?>Alegeti categoria!
Alegeti categoria! ------------------------------------------------------------------------ lista_categ.php ------------------------------------------------------------------------
Alegeti categoria:
Nr. | Categorie | Total Produse |
Toate Categoriile |
Total produse:
------------------------------------------------------------------------ formular.php ------------------------------------------------------------------------Pret total (fara TVA): $lista_categ) foreach ($lista_categ as $prod => $cant) { $pret += $cant*$produse[$categ][$prod]['pret']; $afis .= "+".$cant."x".$produse[$categ][$prod]['pret']; } echo $pret; ?>
Obtinut astfel:
Pret total (cu TVA):
"; print_r ($_POST); echo ""; ?>
Comanda receptionata la data:
------------------------------------------------------------------------ SQL ------------------------------------------------------------------------ Database: lab , User: lab_user:masteretti ------------------------------------------------------------------------ magazin.sql ------------------------------------------------------------------------ -- MySQL Administrator dump 1.4 -- -- ------------------------------------------------------ -- Server version 5.0.19-nt /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -- -- Create schema lab -- crearea bazei de date problematica in phpmyadmin, se creaza manual -- -- CREATE DATABASE IF NOT EXISTS lab; -- USE lab; -- -- Definition of table `categorii` -- DROP TABLE IF EXISTS `categorii`; CREATE TABLE `categorii` ( `id_categ` int(10) unsigned NOT NULL auto_increment, `nume` varchar(45) NOT NULL, `detalii` varchar(150) default NULL, PRIMARY KEY (`id_categ`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `categorii` -- /*!40000 ALTER TABLE `categorii` DISABLE KEYS */; INSERT INTO `categorii` (`id_categ`,`nume`,`detalii`) VALUES (1,'papetarie',NULL), (2,'instrumente',NULL), (3,'audio-video',NULL); /*!40000 ALTER TABLE `categorii` ENABLE KEYS */; -- -- Definition of table `produse` -- DROP TABLE IF EXISTS `produse`; CREATE TABLE `produse` ( `id_produs` int(10) unsigned NOT NULL auto_increment, `id_categ` int(10) unsigned NOT NULL, `nume` varchar(45) NOT NULL, `detalii` varchar(150) default NULL, `cant` int(10) unsigned default NULL, `pret` float default NULL, PRIMARY KEY (`id_produs`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `produse` -- /*!40000 ALTER TABLE `produse` DISABLE KEYS */; INSERT INTO `produse` (`id_produs`,`id_categ`,`nume`,`detalii`,`cant`,`pret`) VALUES (1,1,'carte','mai multe pagini scrise legate',0,100), (2,1,'caiet','mai multe pagini goale legate',0,75), (3,1,'hartie scris','mai multe pagini goale NElegate',0,50), (4,2,'penar','loc de depozitat instrumente de scris',0,150), (5,2,'stilou','instrument de scris albastru',0,125), (6,2,'creion','instrument de scris gri',0,25), (7,3,'cd','canta',0,50), (8,3,'dvd','vizual',0,100), (9,3,'blue ray','vizual extrem',0,500); /*!40000 ALTER TABLE `produse` ENABLE KEYS */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;