HI
Mir viel leider kein besserer Namen ein für den Titel sorry dafür.
Ich stekce seit ca einer Woche mit einem Problem fest, und komme einfach nicht mehr weiter. Kann mir jemand helfen dies zu erweitern?
Wäre super dankbar wenn mir jemand helfen würde.
Als erstes habe ich diese Tabellen:
products: Hier stehen die Produkte drin.
products_attributes: Hier stehen die Atribute zu den Kategorien drin.
products_attributes_cat: Hier stehen die Attributkategorien drin.
warenkorb: Hier werden die Produkte eingetragen.
Ich hatte nun das so, dass mir die Produkte in den Warenkorb gespeichert wurden. Nun wollte ich es mit Attributen erweitern. Soweit sogut. Jedoch:
Ich mache nun mit einer WHILE schleife options felder wie folgt:
In der Form hat es ein hidden Feld für send und sende das ganze per POST.
So und nun zum Grossen Problem.
Ich hätte gerne eine weitere Tabelle warenkorb_attribute als beispiel, wo zum dazugehörigen Produkt die Attribute gespeichert werden.
Zusätzlich das Problem ist:
Wenn ein Produkt bereits eingetragen ist, wo alle Attribute übereinstimmen. Also z.B. Produkt1 Farbe Rot Grösse XL, soll er es nur updaten und die Produkte Menge um 1 erhöhen ansonsten ein neuen eintrag.
Ich habe nun eine Woche sehr viel ausprobiert nichts hat wirklich geklappt. Deshalb habe ich die Tabelle warenkrob_attribut wieder gelöscht, und hoffe mir kann jemand nun hier beim Aufbau weiterhelfen und mir vieleicht ein Codeschnippsel dazu machen. Wäre euch super dankbar.
Danke für jeden hilfreichen Tipp.
Gruss
kari_w
Mir viel leider kein besserer Namen ein für den Titel sorry dafür.
Ich stekce seit ca einer Woche mit einem Problem fest, und komme einfach nicht mehr weiter. Kann mir jemand helfen dies zu erweitern?
Wäre super dankbar wenn mir jemand helfen würde.
Als erstes habe ich diese Tabellen:
Code:
CREATE TABLE `products` ( `product_id` int(11) unsigned NOT NULL auto_increment, `product_name` varchar(250) NOT NULL default '0', `product_desc` text NOT NULL, `cat_id` int(11) unsigned NOT NULL default '0', `scat_id` int(11) unsigned NOT NULL default '0', `product_date` int(11) unsigned NOT NULL default '0', `prodnr` varchar(50) NOT NULL default '0', `product_preis_eu` varchar(10) NOT NULL default '0', PRIMARY KEY (`product_id`) ) TYPE=MyISAM; INSERT INTO `products` (`product_id`, `product_name`, `product_desc`, `cat_id`, `scat_id`, `product_date`, `prodnr`, `product_thub`, `product_pic`, `product_preis_eu`) VALUES (1, 'Produkt1', 'Beschreibung\r\nBeschreibung\r\nBeschreibung\r\nBeschreibung', 6, 2, 1075825731, '000001', '45,50'); INSERT INTO `products` (`product_id`, `product_name`, `product_desc`, `cat_id`, `scat_id`, `product_date`, `prodnr`, `product_thub`, `product_pic`, `product_preis_eu`) VALUES (2, 'Produkt2', 'Beschreibung', 6, 2, 1075837981, '000002', '13,25'); CREATE TABLE `products_attributes` ( `attribut_id` int(11) unsigned NOT NULL auto_increment, `attribut_cat_id` int(11) NOT NULL default '0', `attribut_name` varchar(250) NOT NULL default '0', `attribut_cat_prefix` char(1) NOT NULL default '0', `attribut_preis` varchar(10) NOT NULL default '0', PRIMARY KEY (`attribut_id`) ) TYPE=MyISAM; INSERT INTO `products_attributes` (`attribut_id`, `attribut_cat_id`, `attribut_name`, `attribut_cat_prefix`, `attribut_preis`) VALUES (1, 1, 'Grün', '+', '0'); INSERT INTO `products_attributes` (`attribut_id`, `attribut_cat_id`, `attribut_name`, `attribut_cat_prefix`, `attribut_preis`) VALUES (2, 1, 'Gelb', '+', '0'); INSERT INTO `products_attributes` (`attribut_id`, `attribut_cat_id`, `attribut_name`, `attribut_cat_prefix`, `attribut_preis`) VALUES (3, 1, 'Rot', '+', '0'); INSERT INTO `products_attributes` (`attribut_id`, `attribut_cat_id`, `attribut_name`, `attribut_cat_prefix`, `attribut_preis`) VALUES (4, 2, 'L', '+', '0'); INSERT INTO `products_attributes` (`attribut_id`, `attribut_cat_id`, `attribut_name`, `attribut_cat_prefix`, `attribut_preis`) VALUES (5, 2, 'XL', '+', '5,00'); INSERT INTO `products_attributes` (`attribut_id`, `attribut_cat_id`, `attribut_name`, `attribut_cat_prefix`, `attribut_preis`) VALUES (6, 2, 'XXL', '+', '10,00'); CREATE TABLE `products_attributes_cat` ( `attribut_cat_id` int(11) unsigned NOT NULL auto_increment, `product_id` int(11) NOT NULL default '0', `attribut_cat_name` varchar(250) NOT NULL default '0', PRIMARY KEY (`attribut_cat_id`) ) TYPE=MyISAM; INSERT INTO `products_attributes_cat` (`attribut_cat_id`, `product_id`, `attribut_cat_name`) VALUES (1, 1, 'Farbe'); INSERT INTO `products_attributes_cat` (`attribut_cat_id`, `product_id`, `attribut_cat_name`) VALUES (2, 1, 'Grösse'); CREATE TABLE `warenkorb` ( `wkid` int(11) unsigned NOT NULL auto_increment, `userid` int(11) unsigned NOT NULL default '0', `prodid` int(11) NOT NULL default '0', `prodmenge` int(11) NOT NULL default '0', `prodstp` varchar(10) NOT NULL default '0', PRIMARY KEY (`wkid`) ) TYPE=MyISAM; INSERT INTO `warenkorb` (`wkid`, `userid`, `prodid`, `prodmenge`, `prodstp`) VALUES (13, 1, 1, 1, '45,50'); INSERT INTO `warenkorb` (`wkid`, `userid`, `prodid`, `prodmenge`, `prodstp`) VALUES (12, 1, 1, 1, '45,50');
products: Hier stehen die Produkte drin.
products_attributes: Hier stehen die Atribute zu den Kategorien drin.
products_attributes_cat: Hier stehen die Attributkategorien drin.
warenkorb: Hier werden die Produkte eingetragen.
Ich hatte nun das so, dass mir die Produkte in den Warenkorb gespeichert wurden. Nun wollte ich es mit Attributen erweitern. Soweit sogut. Jedoch:
Ich mache nun mit einer WHILE schleife options felder wie folgt:
PHP-Code:
$proddet_attribut=mysql_query("SELECT * FROM products_attributes_cat WHERE product_id='$_GET[prid]'");
while($row_attributes = $db->fetch_array($proddet_attribut)) {
$proddet_attributbit=mysql_query("SELECT * FROM products_attributes WHERE attribut_cat_id='$row_attributes[attribut_cat_id]'");
$seln="auswahl_".$row_attributes['attribut_cat_id'];
$options.="<select size=\"1\" name=\"$seln\">";
while($row_attributesbit = mysql_fetch_array($proddet_attributbit)) {
$options.="<option value=\"$row_attributesbit[attribut_id]\">$row_attributesbit[attribut_name]</option>";
}
}
PHP-Code:
if(isset($_POST['send'])) {
Ich hätte gerne eine weitere Tabelle warenkorb_attribute als beispiel, wo zum dazugehörigen Produkt die Attribute gespeichert werden.
Zusätzlich das Problem ist:
Wenn ein Produkt bereits eingetragen ist, wo alle Attribute übereinstimmen. Also z.B. Produkt1 Farbe Rot Grösse XL, soll er es nur updaten und die Produkte Menge um 1 erhöhen ansonsten ein neuen eintrag.
Ich habe nun eine Woche sehr viel ausprobiert nichts hat wirklich geklappt. Deshalb habe ich die Tabelle warenkrob_attribut wieder gelöscht, und hoffe mir kann jemand nun hier beim Aufbau weiterhelfen und mir vieleicht ein Codeschnippsel dazu machen. Wäre euch super dankbar.
Danke für jeden hilfreichen Tipp.
Gruss
kari_w
Kommentar