jonathanbee Posted September 27, 2007 Share Posted September 27, 2007 I've added a 4th field to my TABLE_ORDER, but I can't figure out how to insert data into this new field.. The variable is called mailingList. Advice very appreciated! -------------------- in confirm.php: -------------------- //database stuff $order = new order($email); $orderNumber = $order->saveOrder($db); //end database stuff -------------------- in order.class.php: -------------------- <?php class order { var $email; function order($email) { $this->email = $email; } function saveOrder($db) { $query = "INSERT into `" . TABLE_ORDER . "`(`o_id`, `date`, `email`) VALUES('', now(), '" . $this->email . "')"; $db->execute($query); return $this->getMaxOrderNumber($db); } function getMaxOrderNumber($db) { $result = $db->execute("SELECT MAX(`o_id`) FROM `" . TABLE_ORDER . "`"); return $result->fields['MAX(`o_id`)']; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/70823-solved-how-can-i-add-data-to-my-new-field/ Share on other sites More sharing options...
teng84 Posted September 27, 2007 Share Posted September 27, 2007 show how you put value on your mail variable or try $order->saveOrder($db ,'newfield'); //your function function saveOrder($db, $newfield) { $query = "INSERT into `" . TABLE_ORDER . "`(`o_id`, `date`, `email`, `newfield`) VALUES('', now(), '" . $this->email . "','$newfield')"; $db->execute($query); return $this->getMaxOrderNumber($db); } Quote Link to comment https://forums.phpfreaks.com/topic/70823-solved-how-can-i-add-data-to-my-new-field/#findComment-356079 Share on other sites More sharing options...
jonathanbee Posted September 27, 2007 Author Share Posted September 27, 2007 Thanks!!! I used your code, but just changed: $order->saveOrder($db ,'newfield'); to $order->saveOrder($db , $newfield); works great! Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/70823-solved-how-can-i-add-data-to-my-new-field/#findComment-356086 Share on other sites More sharing options...
teng84 Posted September 27, 2007 Share Posted September 27, 2007 i never thought you will use my var name that ugly name your varaible(always) base on it use or function any ways good job Quote Link to comment https://forums.phpfreaks.com/topic/70823-solved-how-can-i-add-data-to-my-new-field/#findComment-356089 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.