killay Posted November 25, 2008 Share Posted November 25, 2008 HiI have an open source script which I'm trying to modify (shop-script)The problem is when a product is added, no date of creation is set in the database (mysql).Thats what I'm trying to add.But problem is I have not the required knowledge for that.So I was hoping you guys could help me with that. //add new product db_query("INSERT INTO ".PRODUCTS_TABLE." (categoryID, name, description, customers_rating, Price, in_stock, customer_votes, items_sold, enabled, brief_description, list_price, product_code, picture, thumbnail, big_picture) VALUES ('".$_POST["categoryID"]."','".$_POST["name"]."','".$_POST["description"]."', 0, '".$_POST["price"]."', ".$instock.", 0, 0, 1, '".$_POST["brief_description"]."', '".$_POST["list_price"]."', '".$_POST["product_code"]."','','','');") or die (db_error()); $pid = db_insert_id(); $dont_update = 1; //don't update product $s = ""; $s1 = "UPDATE ".PRODUCTS_TABLE." SET categoryID=categoryID"; this is the code to add a new product (says in the comment).I already made a field in the database called 'created_at' with type datetime, null=no, format= 0000-00-00 00:00:00.Found this format in my other databases :)So is there anyone who could help me with this?Or maybe provide me with a link where I can find the solution?Kind regardsPeter Link to comment Share on other sites More sharing options...
Lulzim Posted November 25, 2008 Share Posted November 25, 2008 it should look like this <?php db_query("INSERT INTO ".PRODUCTS_TABLE." (categoryID, name, description, customers_rating, Price, in_stock, customer_votes, items_sold, enabled, brief_description, list_price, product_code, picture, thumbnail, big_picture, created_at) VALUES ('".$_POST["categoryID"]."','".$_POST["name"]."','".$_POST["description"]."', 0, '".$_POST["price"]."', ".$instock.", 0, 0, 1, '".$_POST["brief_description"]."', '".$_POST["list_price"]."', '".$_POST["product_code"]."','','','', '".date("Y-m-d H:i:s")."');") or die (db_error()); you have to add the date column name created_at on the columns list and then under values date("Y-m-d H:i:s") inserts the current date and time from the system. Link to comment Share on other sites More sharing options...
killay Posted November 26, 2008 Author Share Posted November 26, 2008 lol that easy? :)I also had to use it elsewhere to delete a product. Else the product satyed in the databse with all NULL values :)thanks, it works Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.